Knex-Sqlite
Little wrapper library for creating an instance of knex for an sqlite3 database.
Usage
import knexSqlite, { OPEN_READONLY } from 'knex-sqlite';
const knex = knexSqlite(
// Required: the name of your databse
'./my-database.sqlite',
// Optional: the file open mode (defaults to read-write)
OPEN_READONLY,
// Optional: the knex constructor options
{
debug: true
}
);
console.log(await knex.select('*').from('blog_posts'));
Dependencies
knex-sqlite
Knex Sqlite3
-
knex-sqlite
-
static
-
.default ⇒
Knex
-
.OPEN_READONLY :
number
-
.OPEN_READWRITE :
number
-
.OPEN_CREATE :
number
-
.default ⇒
- inner
-
static
Knex
knex-sqlite.default ⇒ Return an instance of knex for an sqlite3 database. The filename and mode arguments are the same as those in the sqlite3 library
Kind: static property of knex-sqlite
Returns: Knex
- Instance of knex library
See: node-sqlite3
Param | Type | Description |
---|---|---|
filename | string |
The database to access |
mode | mode |
The mode to open the database as |
options | object |
Additional knex options |
number
knex-sqlite.OPEN_READONLY : Open file as read only
Kind: static typedef of knex-sqlite
number
knex-sqlite.OPEN_READWRITE : Open file as read-write
Kind: static typedef of knex-sqlite
number
knex-sqlite.OPEN_CREATE : Create the file
Kind: static typedef of knex-sqlite
OPEN_READONLY
| OPEN_READWRITE
| OPEN_CREATE
knex-sqlite~mode : Modes for opening the database with
Kind: inner typedef of knex-sqlite
See: node-sqlite3
knex-sqlite~Knex
Knex instance
Kind: inner external of knex-sqlite
See: Knex