Configuration
SlintORM resolves config from three sources in priority order: CLI flags, slintorm.config.js, then the "slintorm" key in package.json.
ORMManager is the default export and the primary class. Use new ORMManager(config) directly. It gives you a real class instance — supporting instanceof checks, subclassing, and cleaner generic inference for typed db stores. The functional createORM alias exists but is not the recommended pattern.
ORMManagerConfig options
slintorm.config.js
// slintorm.config.js
module.exports = {
driver: 'sqlite',
databaseUrl: './dev.db',
dir: './src', // directory to scan for TypeScript models
logs: false, // log SQL queries
};package.json alternative
// package.json
{
"slintorm": {
"driver": "postgres",
"databaseUrl": "postgresql://user:pass@localhost/mydb",
"dir": "./src"
}
}Driver-specific init examples
SQLite
// db.ts — SQLite
import ORMManager from 'slintorm';
export const orm = new ORMManager({
driver: 'sqlite',
databaseUrl: './dev.db', // path to file, or ':memory:'
dir: './src',
logs: false,
});
await orm.migrate();PostgreSQL
// db.ts — PostgreSQL
import ORMManager from 'slintorm';
export const orm = new ORMManager({
driver: 'postgres',
databaseUrl: process.env.DATABASE_URL!, // postgresql://user:pass@host/db
dir: './src',
});
await orm.migrate();MySQL
// db.ts — MySQL
import ORMManager from 'slintorm';
export const orm = new ORMManager({
driver: 'mysql',
databaseUrl: 'mysql://user:pass@localhost/mydb',
dir: './src',
});
await orm.migrate();MongoDB
// db.ts — MongoDB
import ORMManager from 'slintorm';
export const orm = new ORMManager({
driver: 'mongodb',
databaseUrl: process.env.MONGO_URI!,
dir: './src',
});
await orm.migrate();Typed db store with ModelMap
After running npx slintorm generate, pass the generated ModelMap type to get a fully-typed db object without manual defineModel exports.
The schema option imports the pre-built schema exported from schema/generated.tsand hands it directly to the ORM, skipping the filesystem scan that normally happens at startup. It is not compulsory in Node.js — if omitted, SlintORM scans your dir at runtime instead. It becomes required in edge runtimes (Cloudflare Workers, Next.js Edge, Deno Deploy) where the filesystem is unavailable. Passing it in Node.js is still recommended: it removes the scan overhead and makes startup deterministic.
// db.ts — typed db store via ModelMap
import ORMManager from 'slintorm';
import { schema, type ModelMap } from './schema/generated';
export const orm = new ORMManager<ModelMap>({
driver: 'sqlite',
databaseUrl: './dev.db',
modelMap: {} as ModelMap,
schema, // skips filesystem scan on startup; required on edge runtimes
});
// orm.db.User.insert(...) — fully typed
export const db = orm.db;