Registry / database / trilogy

trilogy

JSON →
library2.0.5jsnpmunverified

A simple Promise-based SQLite layer for TypeScript and JavaScript, supporting both native C++ (sqlite3) and pure JavaScript (sql.js) backends. Version 2.0.5 is the latest stable release. Key differentiators include automatic type casting between JS and SQLite types, swappable backends without code changes, lifecycle hooks, and first-class TypeScript support. It is not an ORM; instead it provides a Mongoose-inspired API for schema-defined models with query building via knex. Suitable for Node.js and Electron environments.

npm install trilogy
INSTALL
IMPORT
SIG · TRILOGY
T
trilogy
databasejavascriptv2.0.5
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.

connect
import { connect } from 'trilogy'
const { connect } = require('trilogy')
Trilogy is ESM-only. Using require() may cause issues in strict ESM contexts.
Model
import { Model } from 'trilogy'
import Model from 'trilogy'
Model is a named export, not a default export.
Types
import { Types } from 'trilogy'
import { types } from 'trilogy'
Type export is capitalized 'Types'.

Demonstrates connecting to a SQLite file, defining a model with automatic type casting, syncing schema, creating a document, querying with conditions, and closing the database.

import { connect, Model, Types } from 'trilogy' const db = connect('./my-database.db') const User = new Model('users', { name: String, age: Number, email: { type: String, required: true }, createdAt: Date }) async function main() { await db.sync() await User.create({ name: 'Alice', age: 30, email: 'alice@example.com' }) const users = await User.find({ age: { $gte: 25 } }) console.log(users) await db.close() } main().catch(console.error)
Debug
Known issues
gotchaBackend driver (sqlite3 or sql.js) must be installed separately as a peer dependency.
fix
Install one of: npm install sqlite3 or npm install sql.js
affects: >=2.0.0
gotchaDefault export is not available; all exports are named.
fix
Use import { connect, Model, Types } from 'trilogy'
affects: >=2.0.0
deprecatedThe callback-based API has been deprecated in favor of Promises.
fix
Use async/await or .then() instead of callbacks.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'sqlite3'
Backend module not installed.
fix
Install sqlite3 or sql.js as a peer dependency.
TypeError: trilogy.connect is not a function
Using default import instead of named import.
fix
Use import { connect } from 'trilogy'
Upgrade
Version history
2.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
Meta
1
Amazon
1
OpenAI (training)
1
Resources
trilogy — npm install trilogy · libregistry