Stratum + Drizzle
Lightweight TypeScript ORM with SQL-like syntax
Drizzle ORM is a lightweight, SQL-first TypeScript ORM. Its thin abstraction over SQL makes it a natural fit for Stratum's PostgreSQL-native features. Drizzle handles your schema and queries. Stratum handles tenant hierarchy, config, isolation, and compliance, both operating on the same database without conflicts.
Step-by-step setup: Drizzle ORM guide in the Stratum docs.
Feature comparison
CapabilityDrizzleStratum
Schema managementDrizzle Kit (push/migrate)Stratum manages tenant tables only
RLS isolationManual via sql`` templateAutomatic policy generation
Schema-per-tenantSchema parameter in table definitionsAutomatic search_path switching
Raw SQL accessFirst-class: sql`` tagged templatesUses pg Pool directly
Config inheritanceNot availableBuilt-in, root-to-leaf resolution
Audit loggingBuild it yourselfEvery mutation, actor-attributed
Connection overheadShares pg PoolShares pg Pool
Bundle sizeMinimal (~30KB)Minimal, no heavy dependencies
Getting started
drizzle-with-stratum.ts
import { drizzle } from "drizzle-orm/node-postgres"; import { Pool } from "pg"; import { Stratum } from "@stratum-hq/lib"; // Shared connection pool const pool = new Pool(); // Drizzle for app queries const db = drizzle(pool); // Stratum for tenancy, same pool const stratum = new Stratum({ pool }); await stratum.initialize(); // Both use the same PostgreSQL connection const tenant = await stratum.createTenant({ name: "Acme", slug: "acme" });
Things to know
- Drizzle and Stratum share a pg Pool. Set pool max connections to account for both.
- Drizzle's schema-aware table definitions work well with Stratum's schema-per-tenant mode.
Start building with Drizzle + Stratum
npm install @stratum-hq/lib pg