Registry / database / sqlite-ts

sqlite-ts

JSON →
library0.1.0jsnpmunverified

sqlite-ts (v0.1.0) is an ORM for SQLite databases targeting TypeScript/JavaScript applications, including React Native and Expo. It provides decorators (@Primary, @Column) to define entities, automatic table creation, and CRUD operations. The library wraps a driver (e.g., node-sqlite3) and simplifies SQLite interactions with transaction support. It differentiates by offering a TypeScript-first API with decorators and a simple entity mapping. No recent releases; likely in early development.

npm install sqlite-ts
INSTALL
IMPORT
SIG · SQLITE-TS
S
sqlite-ts
databasejavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Db
import { Db } from 'sqlite-ts'
const Db = require('sqlite-ts').Db
ESM default; commonjs require uses .Db property.
Column
import { Column } from 'sqlite-ts'
import { Column } from 'sqlite-ts/decorators'
All exports are from root package.
Primary
import { Primary } from 'sqlite-ts'
import { PrimaryKey } from 'sqlite-ts'
The decorator is named Primary, not PrimaryKey.
SQLite3Driver
import { SQLite3Driver } from 'sqlite-ts'
import SQLite3Driver from 'sqlite-ts/driver'
Driver class is exported from main package.

Defines a Person entity with decorators, connects to in-memory SQLite, creates table, and inserts a row.

import { Db, Column, Primary, SQLite3Driver } from 'sqlite-ts'; import sqlite3 from 'sqlite3'; class Person { @Primary() id: number = 0; @Column('NVARCHAR') name: string = ''; @Column('INTEGER') age: number = 0; } const sqliteDb = new sqlite3.Database(':memory:'); const db = await Db.init({ driver: new SQLite3Driver(sqliteDb), entities: { Person }, createTables: false, }); await db.tables.Person.create(); const result = await db.tables.Person.insert({ name: 'Alice', age: 30 }); console.log(result.insertId); // 1 await db.close();
Debug
Known issues
gotchaThe `insert` function does not return primary keys for bulk inserts; only last insertId is returned.
fix
For individual primary keys, insert one by one or use transaction with exec and .then.
affects: >=0.0.0
gotchaEntity classes must have default values for all properties (e.g., id: number = 0) to work with decorators.
fix
Initialize all properties in the class definition.
affects: >=0.0.0
gotchaThe `createTables` option defaults to `false`; tables are not auto-created unless you explicitly call `createAllTables` or `tables.Entity.create()`.
fix
Set `createTables: true` in Db.init or manually create tables after init.
affects: >=0.0.0
gotchaTransactions require calling `exec()` with the promise returned by insert/update/delete, not awaiting directly.
fix
Use `exec(tables.Entity.insert(...))` and attach `.then()` to get individual results.
affects: >=0.0.0
deprecatedThe `require('sqlite3')` style shown in README is outdated for ESM projects.
fix
Use `import sqlite3 from 'sqlite3'` in ESM.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'sqlite-ts'
Package not installed or missing from node_modules.
fix
Run `npm install sqlite-ts sqlite3`
Cannot use decorators in TypeScript without experimentalDecorators
TypeScript compiler requires experimentalDecorators enabled.
fix
Add `"experimentalDecorators": true` to tsconfig.json
Property 'insertId' does not exist on type 'InsertResult'
TypeScript types may be missing or outdated.
fix
Ensure you have the latest version (0.1.0) and check if types are exported correctly.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
sqlite3optionalDefault SQLite driver; required to use the SQLite3Driver shipped with sqlite-ts.
Agent activity
20 hits · last 30 days
node
16
Meta
2
OpenAI (training)
1
Resources