@nano/sqlite (1.0.0)

Published 2 weeks ago by HerrHase

Installation

@nano:registry=https://git.node001.net/api/packages/nano/npm/
npm install @nano/sqlite@1.0.0
"@nano/sqlite": "1.0.0"

About this package

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.

Dependencies

Dependencies

ID Version
better-sqlite3 12.6.*
Details
npm
2 weeks ago
1
Björn Hase
MIT
latest
3.5 KiB
Assets (1)
Versions (4) View all
1.0.0 on 2026-08-05
0.2.1 on 2024-10-21
0.2.0 on 2024-07-25
0.1.0 on 2024-07-21