Quick start
From an empty directory to a working model with real queries, in ten minutes.
Get startedA TypeScript ORM for 27 SQL dialects, 4 graph dialects and ~102 data stores, with the SQL it generates documented on every page. And the control-plane API that provisions and runs them.
From an empty directory to a working model with real queries, in ten minutes.
Get startedWhat each engine supports, where it diverges, and the SQL prorm emits for it.
Browse dialectsAccounts, provisioning, the long-running actions that follow, and the billing and teams around them: 308 operations.
Open the APIEvery operation at api.prod-orm.io, generated from openapi.yml and grouped the way the console is: 308 operations in nine groups.
Install the package, point it at a database and define a model. SQLite needs no server at all, so the snippet on the right runs as-is.
npm install ts-prorm-orm better-sqlite3
import { Prorm, DataTypes } from 'ts-prorm-orm';
const db = new Prorm({
dialect: 'sqlite',
storage: ':memory:',
});
await db.connect();
const User = db.define('User', {
id: { type: DataTypes.INTEGER(),
primaryKey: true,
autoIncrement: true },
name: { type: DataTypes.STRING(100) },
});
await db.sync();
await User.create({ name: 'Ada' });
# Is it up
curl https://api.prod-orm.io/health
# Anything that creates something takes Idempotency-Key
curl -X POST https://api.prod-orm.io/provision/databases \
-H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "name": "notes", "type": "postgres", "size": 1 }'
{ "error": "capability_missing",
"message": "…" }
The API behind prod-orm.io describes a query as select, insert, update or delete, and a schema change as a list of operations. The ORM compiles those for whichever engine they are going to, so no statement a client sends can reach an engine.
Send Idempotency-Key with anything that creates something and a retry replays the first response instead of creating a second thing.
<script src="https://prod-orm.io/cdn/prorm.min.js"></script>
const db = await prorm.openBrowserDatabase({ database: 'notes' });
const Note = db.define('Note', {
title: prorm.DataTypes.STRING,
archived: prorm.DataTypes.BOOLEAN,
});
await db.sync();
await Note.create({ title: 'Hello', archived: false });
await Note.findAll({ where: { archived: false } });
One script tag, no build step: the same models and queries against a real SQLite database in the page, SQLite compiled to WebAssembly where Web SQL is gone. Finders, operators and views all behave as they do on a server.
await User.findAll({
where: { age: { [Op.gte]: 18 } },
order: [['name', 'ASC']],
limit: 10,
});
SELECT "id", "name", "age" FROM "users"
WHERE "age" >= 18
ORDER BY "name" ASC
LIMIT 10;
These ten pages are meant to be read in order; each one assumes only what came before it. After them you can use the ORM for real work. Everything else is reference to reach for when a need comes up.
The first few sections are a path; the rest are reference you come back to.
Clone it, run the suite against a containerised engine, send a patch.
The source, the issue tracker and the pipeline that builds these pages.
RepositoryPublished as ts-prorm-orm. Types are bundled; no @types package needed.