Skip to content

forge-orm examples

Hands-on, runnable examples for forge-orm — Prisma-shape multi-database ORM for MongoDB, PostgreSQL, MySQL, SQLite, DuckDB, and SQL Server from one codebase.

Every example is self-contained (its own package.json). Click the right button on each example's README and it runs — no install on your machine.

Runs in StackBlitz (instant, no signup)

Pure-JS / wasm stacks — boots in your browser tab.

#ExampleDialectFrameworkWhat it shows
01sqlite-browser-todoSQLite (wasm + OPFS)Vite + React"Hello world" — schema, query, mutate in a tab
02sqlite-browser-offline-firstSQLite (wasm + OPFS)Vite + ReactOptimistic UI + queued sync stub
04node-cliPostgres (PGlite)Plain NodeSmallest possible forge-orm program
05hono-pglite-apiPostgres (PGlite)HonoREST CRUD with no external DB
06nextjs-pglite-fullstackPostgres (PGlite)Next.js App RouterServer actions + RSC reads
08geo-searchPostgres (PGlite)Plain Nodef.geoPoint + nearTo
09vector-ragPostgres (PGlite)Plain Nodef.vector(N) + cosine similarity
10recipe-bomPostgres (PGlite)Plain NodeRecursive BOM with sub-recipes
11multi-tenantPostgres (PGlite)Plain NodeRow-level scoping by orgId
12audit-logPostgres (PGlite)Plain NodeMutation log via db.$on("query")
13fulltext-searchPostgres (PGlite)Plain Nodef.text().searchable()
14transactionsPostgres (PGlite)Plain NodeAtomic batch + nested savepoints
15migrations-driftPostgres (PGlite)Plain Nodedb.$migrate() + db.$diff()

Runs in CodeSandbox (auto-runs on click)

Needs a real OS for native bindings. Each has a .codesandbox/tasks.json that auto-installs + runs.

#ExampleDialectWhy
03duckdb-cli-needs-vmDuckDB@duckdb/node-api is a native addon
07bun-cli-needs-vmSQLite (Bun)Bun's built-in SQLite is native

Needs a real DB server (point at a free hosted one)

CodeSandbox VM runs the app, the DB lives in a free hosted tier. Each README has paste-ready .env instructions.

#ExampleDialectFree hosted option
16mongo-atlas-blogMongoDBAtlas free tier
17mssql-merge-erpSQL ServerAzure SQL free tier (12 months)
18postgres-rls-authPostgresNeon, Supabase, Aiven

Sandbox-environment cheat sheet

ServiceFree tierWhat it gives youBest for
StackBlitzUnlimitedBrowser-only Node (WebContainer)Examples 01, 02, 04, 05, 06, 08–15
CodeSandboxFree for public projectsLinux VM, auto-runs tasks.jsonExamples 03, 07 (native) + 16, 17, 18 (hosted DB)

Clone locally

Always fastest — zero latency, native works:

sh
npx degit johnsonfash/forge-orm/examples/04-node-cli my-app
cd my-app && npm install && npm run dev

Conventions

  • Each example pins the latest forge-orm version
  • TypeScript by default
  • README explains the forge-orm-specific bits, not the framework
  • One concept per example
  • Comments call out trade-offs

Adding an example

PRs welcome. Use the existing folders as templates. Aim for under 100 LOC of meaningful code per example.

MIT licensed. Built from the repository's own markdown — README.md, CHANGELOG.md and docs/.