INDEXField notes
kastor guides
Long reads on TypeScript ORMs, migrations, N+1 queries, type safe SQL and running one data layer on every database.
Field notes
GUIDE 01Choosing a TypeScript ORM: what matters and how kastor worksWhat a TypeScript ORM is, what to look for before you pick one, and a full tour of kastor from schema to queries to migrations, plus when to skip an ORM.
GUIDE 02Type safe SQL in TypeScript, from inferred rows to raw queriesHow to get type safe SQL in TypeScript: inferred row types, select narrowing, InferSelect and InferInsert, and raw SQL with typed rows and bound parameters.
GUIDE 03How to avoid N+1 queries in a TypeScript appLearn to spot and avoid N+1 queries in TypeScript: query logging, nested includes in one query, relation counts, select, take inside includes and pagination.
GUIDE 04Database migrations explained, from first table to productionDatabase migrations explained step by step: schema drift, the dev to deploy workflow, rename detection, safe destructive changes and running migrations in CI.
GUIDE 05Next.js with PostgreSQL: a type-safe ORM setup for the App RouterSet up a Next.js Postgres ORM with the App Router: one reusable client, server components, server actions, serverless pools, env vars and migrations on deploy.
GUIDE 06Database seeding in TypeScript that you can run twiceA practical guide to database seeding in TypeScript: typed seed files, idempotent upserts, bulk inserts, related rows, test factories and seeding in CI.
GUIDE 07Building a multi database app in Node.js with one ORMBuild a multi database app in Node.js with one ORM: several clients, shared schema code, dialect differences that matter, cross database tests and switching.
GUIDE 08A SQL Server ORM for Node.js that speaks T-SQL for youUse a SQL Server ORM for Node.js with the mssql driver: pool setup, encryption, Azure SQL, OUTPUT and MERGE, migrations, db pull, transactions and fixes.
GUIDE 09An Oracle ORM in Node.js without Instant ClientSet up an Oracle ORM in Node.js with oracledb thin mode: pools, FREEPDB1 in a local container, identity columns, MERGE upserts, JSON includes and migrations.
GUIDE 10A MongoDB ORM in TypeScript that shares its API with SQLUse a MongoDB ORM in TypeScript with the same schema and queries as SQL: ObjectId ids, $lookup relations, emulated foreign keys, transactions and migrations.
GUIDE 11A Cloudflare D1 ORM for Workers, typed from your schemaUse a Cloudflare D1 ORM in Workers: the wrangler.toml binding, a client per request, batch transactions, migrations with wrangler, local dev and the limits.
GUIDE 12A Turso ORM for TypeScript, built on libSQLSet up a Turso ORM with @libsql/client: url and authToken, local file URLs, embedded replicas, edge runtimes, migrations, one query includes and transactions.
Migrate to kastor
GUIDE 13Migrate from Prisma to kastorMigrate from Prisma to kastor step by step: kastor import prisma converts schema.prisma, client calls map one to one, and migrate baseline keeps your data and history.
GUIDE 14Migrate from Drizzle ORM to kastorMigrate from Drizzle ORM to kastor: map pgTable to table(), eq and and() to where objects, with to include, drizzle-kit to kastor migrate, and keep your data.
GUIDE 15Migrate from TypeORM to kastorMigrate from TypeORM to kastor: decorated entities to table(), repositories and QueryBuilder to findMany and include, relations, transactions and migration history.
GUIDE 16Migrate from Sequelize to kastorMigrate from Sequelize to kastor: models to a TypeScript schema with inferred types, Op filters to where objects, include, transactions, scopes, hooks and the migration history.
GUIDE 17Migrate from Knex to kastorMigrate from Knex to kastor: replace the query builder with typed findMany and include, keep raw SQL where it shines, and move knex migrations to a kastor baseline.
GUIDE 18Migrate from Mongoose to kastorMigrate from Mongoose to kastor on the same MongoDB data: Schema to table(), populate to include, ObjectId refs, lean results, middleware, validators and indexes.
GUIDE 19Coming from Laravel and EloquentComing from Laravel Eloquent: kastor runs in Node, Bun, Deno and edge runtimes, not PHP. Map models, relations, scopes, with(), migrations, seeders and factories.
GUIDE 20Coming from the Django ORMComing from the Django ORM: kastor runs in JavaScript runtimes, not Python. Map models, QuerySets, select_related, Q objects, migrations and fixtures, or share the database.
GUIDE 21Coming from Rails and Active RecordComing from Rails Active Record: kastor runs in JavaScript runtimes, not Ruby. Map models, associations, scopes, includes, migrations and seeds, or share the database.
Framework guides
GUIDE 22kastor with the Next.js App RouterUse kastor as the Next.js App Router ORM: one client across hot reloads, server components, server actions, route handlers, and the edge runtime with Neon, Turso or D1.
GUIDE 23kastor with NuxtUse kastor as the Nuxt ORM: a client in server/utils reused across hot reloads, typed server routes, runtimeConfig for secrets, a Nitro close hook and migrations on deploy.
GUIDE 24kastor with SvelteKitUse kastor as the SvelteKit ORM: a client in $lib/server, typed load functions, form actions with fail(), +server.ts endpoints, private env vars, adapters and migrations.
GUIDE 25kastor with Remix and React RouterUse kastor with React Router 7 framework mode and Remix: a .server module, typed loaders and actions, redirects, hot reload safe pooling, env vars and migrations on deploy.
GUIDE 26kastor with AstroUse kastor as the Astro ORM: server rendered pages, API endpoints and Astro Actions with typed queries, a reused client, server only env vars, adapters and migrations.
GUIDE 27kastor with NestJSUse kastor as the NestJS ORM: a global DbModule with a provider token, ConfigService for the URL, shutdown hooks, typed services, an exception filter and migrations in CI.
GUIDE 28kastor with ExpressUse kastor as the Express ORM: one client per process, async routes, an error middleware for KastorError codes, graceful shutdown, env files, Docker and migrations.
GUIDE 29kastor with FastifyUse kastor as the Fastify ORM: a fastify-plugin that decorates the instance with a typed client, onClose cleanup, schema validated routes, error handling and migrations.
GUIDE 30kastor with HonoUse kastor as the Hono ORM: a typed db variable set by middleware, one client on Node, Bun and Deno, a client per request on Workers, error handling and migrations.
GUIDE 31kastor with AdonisJSUse kastor in AdonisJS 6: validated env vars, a service module and a provider for shutdown, typed controllers, VineJS input, HMR safe reuse and migrations in CI.
GUIDE 32kastor with BunUse kastor as the Bun ORM: bun:sqlite with no driver to install, Postgres through pg, Bun.serve routes, --hot safe client reuse, .env loading and migrations with the CLI.
GUIDE 33kastor with DenoUse kastor as the Deno ORM: npm specifiers in deno.json, a typed client with pg, Deno.serve routes, permissions and env files, --watch reloads and migrations from CI.
GUIDE 34kastor on Cloudflare WorkersUse kastor as the Cloudflare Workers ORM: a client per request from D1, Postgres through Hyperdrive, Turso over HTTP, typed bindings, wrangler config and migrations.
GUIDE 35kastor with Electron and SQLiteUse kastor as the Electron SQLite ORM: better-sqlite3 in the main process, the database in userData, typed IPC through a preload bridge, migrations on startup and packaging.
GUIDE 36kastor on AWS LambdaUse kastor as the AWS Lambda ORM: a client reused across warm invocations, small pools behind RDS Proxy, secrets, esbuild bundling with no engine binary and migrations.