Two query languages. Six databases. Write MongoDB-style filters or native SQL. Both work on every backend. AI-first guardrails, self-correcting errors, and schema discovery built in.
npm install strictdb
The Contract
Drivers change. Your code doesn't.
This is why it's called StrictDB. When MongoDB, PostgreSQL, or Elasticsearch release breaking driver updates, StrictDB absorbs the change internally. Your queries stay identical across every version, every upgrade, every migration.
ORMs break on major upgrades. Prisma, Mongoose, Sequelize - all have forced rewrites between versions. StrictDB won't. The translation layer evolves. Your code doesn't.
Switch databases by changing one URI. Upgrade drivers with npm update.
Your application code stays the same. That's the contract.
You're always afraid to upgrade your databases because new drivers always break something. So most people just stay on older versions saying they'll get around to upgrading - but never do.
Why should the “language” you're writing be different from Mongo to SQL to Elasticsearch? It's data. Give me my data. Get out of the way and let me build what I want.
- TheDecipherist, creator of StrictDB
MongoDB v7, pg breaking changes, Elasticsearch 7→8 - StrictDB absorbs every driver update internally. You change nothing.
Switch from MongoDB to PostgreSQL by changing one URI string. Your application code stays identical.
StrictDB runs an automated analyzer every day that checks every supported driver for changes. When a driver updates, StrictDB absorbs it internally - before it ever reaches your code. This is not a version policy. It's engineered.
StrictDB monitors MongoDB, pg, mysql2, mssql, better-sqlite3, and @elastic/elasticsearch for breaking changes daily.
Unified API
Pass a connection URI and StrictDB auto-detects the backend. MongoDB-style filters translate automatically to SQL WHERE clauses, Elasticsearch Query DSL, and more. Switch databases by changing one string.
import { StrictDB } from 'strictdb'; // Auto-detects backend from URI const db = await StrictDB.create({ uri: process.env.DATABASE_URL }); // Same syntax - any database const admins = await db.queryMany('users', { role: 'admin', status: { $in: ['active', 'pending'] }, age: { $gte: 18 } }, { sort: { createdAt: -1 }, limit: 50 }); // Works on Mongo, Postgres, MySQL, // MSSQL, SQLite, Elasticsearch
Two-Way Query Engine
MongoDB-style filters auto-translate to SQL WHERE clauses, Elasticsearch Query DSL, and more. Native SQL auto-translates to MongoDB aggregate pipelines. Write in whatever you think in, run on whatever you need.
// This filter works on ALL 6 backends const admins = await db.queryMany('users', { role: 'admin', status: { $in: ['active', 'pending'] }, age: { $gte: 18 } }, { sort: { name: 1 }, limit: 50 }); // On PostgreSQL, becomes: // SELECT * FROM "users" // WHERE "role" = 'admin' // AND "status" IN ('active','pending') // AND "age" >= 18 // ORDER BY "name" ASC LIMIT 50
// This SQL works on ALL 6 backends const results = await db.sql(` SELECT u.name, COUNT(o.id) as orders FROM users u JOIN orders o ON u.id = o.user_id WHERE u.status = 'active' GROUP BY u.name HAVING COUNT(o.id) > 5 ORDER BY orders DESC LIMIT 10 `); // On MongoDB, becomes: // $lookup → $unwind → $match → // $group → $match → $sort → $limit
Same results. Same database. Your choice of syntax.
Everything Built In
No models, no migrations, no magic. StrictDB is a unified database driver with safety rails and AI-first discovery tools.
AI agents explore your schema with describe() - field names, types, indexes, and example filters. No more hallucinated column names.
Empty-filter deletes, unbounded queries, and accidental mass updates are blocked by default. Production-safe from day one.
Catch schema mismatches and bad fields before executing with validate(). Zero wasted database round-trips.
Every error includes a .fix field with the exact corrective action. AI reads the fix and self-corrects - no stack-trace parsing.
Every write returns a structured receipt - matched, modified, inserted, deleted counts plus duration. Never wonder what happened.
14 tools exposed via Model Context Protocol. Connect Claude, GPT, or any MCP-compatible agent for safe, guardrailed database access.
AI-First Design
Every feature is designed so AI agents can discover schemas, validate queries, understand translations, and self-correct - without ever running dangerous operations.
AI explores your database structure without guessing. Returns field names, types, nullability, enums, indexes, and example filters.
const schema = await db.describe('users'); // { // name: 'users', // backend: 'sql', // fields: [ // { name: 'email', type: 'string', required: true }, // { name: 'role', type: 'string', enum: ['admin','user'] }, // ], // indexes: [...], // documentCount: 12847 // }
Catch errors before they execute. Schema mismatches, type errors, and bad field names are caught instantly - no database round-trip.
const check = await db.validate('users', { filter: { role: 'admin' }, doc: { email: 'test@test.com' } }); // { valid: true, errors: [] } // or { valid: false, errors: [ // { field: 'rol', message: 'Unknown field', // expected: 'role' } // ]}
See the exact native query that will execute on your backend. Full transparency into MongoDB-to-SQL translation.
const plan = await db.explain('users', { filter: { role: 'admin' }, limit: 50 }); // { // backend: 'sql', // native: 'SELECT * FROM "users" // WHERE "role" = $1 LIMIT 50' // }
Every error includes a .fix field with the exact corrective action. AI reads the fix and self-corrects on the next attempt.
catch (err) { err.code // 'DUPLICATE_KEY' err.fix // 'Use updateOne() instead // or check with queryOne() first' err.retryable // false } // AI reads .fix → self-corrects // No stack-trace parsing needed
Safety First
Dangerous operations are blocked by default. Not warnings - hard blocks. Override only with explicit confirmation.
deleteMany({}) would delete all documents
updateMany({}) would update all documents
deleteOne({}) would delete an arbitrary row
queryMany() without a limit returns everything
// This is blocked: await db.deleteMany('logs', {}); // This is allowed (explicit intent): await db.deleteMany('logs', { _id: { $exists: true } }, { confirm: 'DELETE_ALL' } );
Model Context Protocol
The StrictDB MCP server exposes 14 tools to any MCP-compatible AI agent.
Set STRICTDB_URI and your agent has guardrailed access across all six backends.
npm install -g strictdb-mcp
Works with Claude, GPT, and any MCP-compatible agent
View strictdb-mcp on npm
Transparency
No more void returns. Every operation gives you matched, modified, inserted, and deleted counts plus execution duration.
const receipt = await db.insertOne('users', { email: 'new@example.com', name: 'New User' }); // { // operation: 'insertOne', // collection: 'users', // success: true, // insertedCount: 1, // duration: 12 // }
Lifecycle Events
Typed events for connections, operations, slow queries, guardrail blocks, and more.
db.on('slow-query', ({ collection, operation, durationMs }) => { logger.warn(`Slow: ${collection}.${operation}` + ` took ${durationMs}ms`); }); db.on('guardrail-blocked', ({ collection, operation, reason }) => { logger.error(`Blocked: ${reason}`); });
Philosophy
No magic. No hidden complexity. Just a unified driver with safety rails.
No models, no Active Record, no entity decorators, no migration files.
No method chaining, no fluent API, no builder patterns.
No lowest-common-denominator approach. Access the native driver with db.raw() anytime.
How It Compares
| Feature | StrictDB | Prisma / Drizzle | Native Drivers |
|---|---|---|---|
| Unified multi-DB API | ✓ 6 backends | ~ SQL only | ✗ One each |
| Two-way query languages | ✓ Filters + SQL | ✗ SQL only | ✗ Native only |
| SQL on MongoDB | ✓ Full engine | ✗ | ✗ |
| Stable API contract | ✓ Never breaks | ✗ Breaking versions | ✗ Breaking versions |
| Schema discovery | ✓ describe() |
✗ | ✗ |
| Dry-run validation | ✓ validate() |
✗ | ✗ |
| Self-correcting errors | ✓ .fix field |
✗ | ✗ |
| Safety guardrails | ✓ Hard blocks | ~ Partial | ✗ |
| MCP server | ✓ 14 tools | ✗ | ✗ |
| Operation receipts | ✓ Every write | ~ Varies | ~ Varies |
| Elasticsearch support | ✓ | ✗ | ~ Separate |
| No code generation | ✓ | ✗ Required | ✓ |
| Zero config | ✓ Just a URI | ✗ Schema files | ✓ |
And More
Mix inserts, updates, and deletes in a single batch() call. Transactional when the backend supports it.
Automatic createdAt and updatedAt injection on writes. Toggle on with a single config flag.
Exponential backoff with configurable max attempts, delays, and multiplier. Your app stays alive.
Full transaction support across MongoDB (replica set), PostgreSQL, MySQL, MSSQL, and SQLite.
SQL column whitelisting, ES internal field blocking, regex complexity limits. Bad input never reaches your database.
Register Zod schemas for collections. StrictDB generates DDL for SQL backends and validates all writes automatically.
One install. One API. Six databases. AI-ready from the first line.
npm install strictdb