parent
10c3fcdf28
commit
05720416fd
@ -1,7 +1,59 @@
|
||||
# Nano Sqlite
|
||||
|
||||
Functions and Classes for handle sqlite in [Bun](https://bun.sh/).
|
||||
Functions and Classes for handle sqlite in [Bun](https://bun.sh/).
|
||||
|
||||
## Function runMigrationSqlite(filePath: string, db: object)
|
||||
## Function getOrCreateSqlite(options = {})
|
||||
## Abstract Class Store
|
||||
## API
|
||||
|
||||
### getOrCreateSqlite(options = {})
|
||||
|
||||
Options are using default Parameters from [Bun](https://bun.sh/docs/api/sqlite). There
|
||||
path can be set by .env
|
||||
|
||||
```
|
||||
NANO_SQLITE_PATH="./../storage/db.sqlite"
|
||||
```
|
||||
|
||||
or by parameter,
|
||||
|
||||
```
|
||||
const db = getOrCreateSqlite({ path: './../storage/db.sqlite' })
|
||||
```
|
||||
|
||||
Per Default WAL mode is enabled. To disable add parameter "wal",
|
||||
|
||||
```
|
||||
const db = getOrCreateSqlite({ path: './../storage/db.sqlite', 'wal': false })
|
||||
```
|
||||
|
||||
### runMigrationSqlite(filePath: string, db: object)
|
||||
|
||||
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. There
|
||||
are no functions to validating Columns.
|
||||
|
||||
```
|
||||
class <store-name>Store extends Store {
|
||||
constructor(db) {
|
||||
super(db, '<table-name>')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### findOneById(id: integer)
|
||||
|
||||
Getting single row by Id.
|
||||
|
||||
#### create(data: object)
|
||||
|
||||
Create a new row in a Table.
|
||||
|
||||
#### update(id: integer, data: object)
|
||||
|
||||
Update single row by Id.
|
||||
|
||||
#### remove(id: integer)
|
||||
|
||||
Remove single row by Id.
|
||||
|
@ -1,2 +0,0 @@
|
||||
[install.scopes]
|
||||
"@nano" = "https://git.node001.net/api/packages/nano/npm/"
|
Loading…
Reference in new issue