Functions and Classes for handle Sqlite in Bun
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Go to file
HerrHase 9c49ec68ba
change from typescript to javascript
2 weeks ago
resources change from typescript to javascript 2 weeks ago
src change from typescript to javascript 2 weeks ago
test change from typescript to javascript 2 weeks ago
.gitignore Initial commit 2 years ago
LICENSE change from typescript to javascript 2 weeks ago
README.md change from typescript to javascript 2 weeks ago
index.js change from typescript to javascript 2 weeks ago
package-lock.json change from typescript to javascript 2 weeks ago
package.json change from typescript to javascript 2 weeks ago

README.md

Nano Sqlite

Functions and Classes for handle Sqlite with Better-Sqlite3

API

getOrCreateSqlite(options = {})

The uri of the Sqlite can be set in the .env-file,

NANO_SQLITE_PATH="./../storage/db.sqlite"

or by Parameter in options,

const db = getOrCreateSqlite({ uri: './../storage/db.sqlite' })
const db = getOrCreateSqlite({ uri: ':memory:' })

Per Default WAL mode is enabled. To disable add Parameter "wal" and set to false,

const db = getOrCreateSqlite({ uri: './../storage/db.sqlite', wal: false })

runMigrationSqlite(filePath: string, db: object)

This functions Reads SQL-Files from a Directory and execute them in the Sqlite.

Store

Store is a Abstract Class to extend a Class for an Single Table. Set the name of the table in super(). There is no handling of columns or validating if the exists.

class <store-name>Store extends Store {
    constructor(db) {
        super(db, '<table-name>')
    }
}

findOneById(id)

Getting single row by id.

create(data)

Create a new row in a Table.

update(id, data)

Update single row by id.

remove(id)

Remove single row by id.