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.
Step-by-step setup: PostgreSQL adapters for Sequelize in the Stratum docs.
Feature comparison
CapabilitySequelizeStratum
Schema managementSequelize CLI migrationsStratum manages tenant tables only
RLS isolationManual: raw queries onlyAutomatic policy generation
Schema-per-tenantManual schema option per modelAutomatic search_path switching
Default scopesdefaultScope for tenant filteringDatabase-level enforcement via RLS
Config inheritanceNot availableBuilt-in, root-to-leaf resolution
Audit loggingHooks (afterCreate, etc.)Every mutation, actor-attributed
GDPR export/purgeBuild it yourselfBuilt-in per-tenant operations
TypeScript supportDecorators or manual typingNative 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