Registry / database / als-sqlite

als-sqlite

JSON →
library0.5.2jsnpmunverified

als-sqlite is a lightweight ORM-like wrapper around better-sqlite3 inspired by Mongoose. It provides Schema definitions with types (text, integer, array, json), encryption support, and a Model class for CRUD operations (insert, find, update, delete) with methods like populate, count, and insertMany. The package is in early stages (v0.5.2, under active development) with frequent breaking changes. It is simpler than full ORMs like Sequelize or TypeORM but lacks mature features and community adoption. Database connectivity is managed via a single connect function.

npm install als-sqlite
INSTALL
IMPORT
SIG · ALS-SQLITE
A
als-sqlite
databasejavascriptv0.5.2
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.

Schema
const { Schema } = require('als-sqlite')
const Schema = require('als-sqlite')
Named export, not default.
Model
const { Model } = require('als-sqlite')
import { Model } from 'als-sqlite'
Not ESM compatible; use CommonJS require.
connect
const { connect } = require('als-sqlite')
const connect = require('als-sqlite').connect;
Same as Schema/Model.

Complete example: define schema, connect to sqlite, create model, insert/find/update/delete records.

const { Schema, Model, connect } = require('als-sqlite'); const path = require('path'); // Define schema const userSchema = new Schema({ name: { type: 'text', default: '' }, age: { type: 'integer' }, email: { type: 'text', default: '', unique: true }, }); // Connect to database const dbPath = path.join(__dirname, 'test.db'); Model.db = connect(dbPath); // Create model const User = new Model('users', userSchema); // Insert a user const newUser = User.insert({ name: 'Alice', age: 30, email: 'alice@example.com' }); console.log('Inserted:', newUser); // Find users const users = User.find({ age: 30 }); console.log('Found:', users); // Update User.update({ name: 'Alice' }, { age: 31 }); console.log('Updated'); // Delete User.delete({ name: 'Alice' }); console.log('Deleted');
Debug
Known issues
breakingModel.drop behavior changed in 0.5.2 to use DROP TABLE IF EXISTS; previously error if table missing.
fix
Upgrade to >=0.5.2 to avoid errors on dropping non-existent tables.
affects: <0.5.2
breakingModel.table() added in 0.5.0; existing code using old instantiation may break.
fix
Update to use new Model.table(tableName, schema) if needed.
affects: <0.5.0
gotchaBoolean conversion on create/update and find was added in 0.4.1; 'true'/'false' strings become actual booleans.
fix
Be aware that string 'true'/'false' will be coerced to boolean after 0.4.1.
affects: <0.4.1
deprecatedNo versioning policy; breaking changes often in minor/patch releases.
fix
Pin exact version in package.json to avoid surprises.
affects: >=0.0.0
gotchaESM not supported; only CommonJS require works.
fix
Use require() and avoid import/export syntax.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Schema is not a constructor
Using default import instead of named import.
fix
const { Schema } = require('als-sqlite')
Error: Cannot find module 'better-sqlite3'
Missing peer dependency better-sqlite3.
fix
npm install better-sqlite3
TypeError: Cannot read property 'db' of undefined
Model.db not set before using Model.
fix
Set Model.db = connect(path) after requiring Model.
Upgrade
Version history
0.5.2latest on npm
Audit
Dependencies
better-sqlite3requiredCore sqlite3 driver used internally
Agent activity
28 hits · last 30 days
node
22
OpenAI (training)
1
Resources
als-sqlite — npm install als-sqlite · libregistry