Compare
Stratum + Sequelize
Established Node.js ORM with Active Record pattern
Sequelize is one of the oldest and most established Node.js ORMs, used in thousands of production applications. Stratum works alongside Sequelize, handling the multi-tenancy infrastructure that Sequelize does not provide. Sequelize manages your models and queries. Stratum manages tenant hierarchy, config, isolation, and compliance.
Feature comparison
| Capability | Sequelize | Stratum |
|---|---|---|
| Schema management | Sequelize CLI migrations | Stratum manages tenant tables only |
| RLS isolation | Manual: raw queries only | Automatic policy generation |
| Schema-per-tenant | Manual schema option per model | Automatic search_path switching |
| Default scopes | defaultScope for tenant filtering | Database-level enforcement via RLS |
| Config inheritance | Not available | Built-in, root-to-leaf resolution |
| Audit logging | Hooks (afterCreate, etc.) | Every mutation, actor-attributed |
| GDPR export/purge | Build it yourself | Built-in per-tenant operations |
| TypeScript support | Decorators or manual typing | Native TypeScript + Zod |
Getting started
sequelize-with-stratum.ts
import { Sequelize } from "sequelize"; import { Pool } from "pg"; import { Stratum } from "@stratum-hq/lib"; // Sequelize for your app models const sequelize = new Sequelize(process.env.DATABASE_URL); // Stratum for tenancy const pool = new Pool(); const stratum = new Stratum({ pool }); await stratum.initialize(); // Tenant hierarchy + config, independent of Sequelize const root = await stratum.createTenant({ name: "Enterprise Co", slug: "enterprise" }); await stratum.setConfig(root.id, "max_seats", { value: 500, locked: true });
Things to know
- Sequelize manages its own connection pool separate from Stratum's pg Pool.
- Sequelize's defaultScope tenant filtering is application-level only. Stratum's RLS enforces at the database level.
- When using schema-per-tenant, set Sequelize's schema option per model to match Stratum's tenant schema.
Start building with Sequelize + Stratum
npm install @stratum-hq/lib pg