@spinajs/orm-sqlite
v2.0.543
Published
framework orm sql-lite language module
Readme
@spinajs/orm-sqlite
The SQLite dialect driver for @spinajs/orm, built on
@spinajs/orm-sql.
Install
npm install @spinajs/orm @spinajs/orm-sqliteUsage
import { DI } from '@spinajs/di';
import { Orm } from '@spinajs/orm';
import { SqliteOrmDriver } from '@spinajs/orm-sqlite';
DI.register(SqliteOrmDriver).as('orm-driver-sqlite');
await DI.resolve(Orm);// configuration
{
db: {
DefaultConnection: 'sqlite',
Connections: [
{
Name: 'sqlite',
Driver: 'orm-driver-sqlite',
Filename: './data/app.sqlite', // or ':memory:'
Pool: { Max: 4 }, // sizes the READ-ONLY handle pool
Migration: { OnStartup: true },
},
],
},
}What is distinctive
Pool.Maxsizes read-only handles, not writers. SQLite serializes writers at the file level, so extra writer handles buy nothing and inviteSQLITE_BUSY. The driver opensMax - 1read handles instead, skipped entirely for:memory:and anonymous temporary databases.- The only driver with
RETURNING(insertReturning: true), so generated keys come back exactly — including from multi-row inserts. SERIALIZABLEis the only isolation level, because sqlite3 outside shared-cache mode serializes file access and that is SERIALIZABLE.- No database events, no
TRUNCATE(aDELETEstands in, and the auto-increment counter is not reset), and multi-columnORDER BYis reduced to one column. - No auto-increment column inside a composite primary key — the compiler throws rather than emit invalid SQL.
Documentation
Full documentation lives in docs/.
| | Page | | --- | --- | | 01 | Configuration | | 02 | Dialect notes |
Development
npm test # unit suite, no server needed
npm run test:integration # creates and removes a temporary on-disk database
npm run build