No build step, no types, no decorators — require the package and go. Every
example on this page runs as written on Node 18+.There are two other ways in: TypeScript, which adds
types to the same calls, and decorators, which
declare models as classes. They produce identical models; pick the one that
matches your codebase.Install#
npm install ts-prorm-orm better-sqlite3
pnpm add ts-prorm-orm better-sqlite3
yarn add ts-prorm-orm better-sqlite3
bun add ts-prorm-orm better-sqlite3
The driver is a separate package because prorm ships none of them; npx orm-cli
packages picks the ones you need if you would rather be asked.SQLite needs no server, so it is the fastest way to have something working.
Swap the driver later — the code below does not change.Connect#
[!WARNING]
A CommonJS file (require) cannot use await at the top level — Node stops
with SyntaxError: await is only valid in async functions and the top level
bodies of modules. The fragments on this page show the calls on their own;
in a .js CommonJS file, put them inside an async function, as in
the whole thing below. ES modules (.mjs, or
"type": "module") allow top-level await.
Define a model#
The table sync() creates depends on the engine; the model does not:createdAt and updatedAt were not declared: timestamps are on unless you pass
timestamps: false.Use it#
The whole thing#
ES modules#
If your package is "type": "module", the import is the only difference — and
top-level await becomes available:my-app/
package.json # no "type", or "type": "commonjs"
index.js # const { Prorm } = require('ts-prorm-orm')
my-app/
package.json # "type": "module"
index.js # import { Prorm } from 'ts-prorm-orm'
Next#
Models — columns, defaults, options The deep reference is shared across all three styles — start at
Start here. The examples there are written in TypeScript,
but the runtime calls are identical: drop the type annotations and they are
JavaScript. Modified at 2026-10-04 00:40:16