v0.2.3 - Now on npm

One API. Six Databases.
Zero Guesswork.

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
StrictDB - The guardian of your database layer
MongoDB PostgreSQL MySQL MSSQL SQLite Elasticsearch

Your code never changes. Ever.

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

🔄

Driver Updates

MongoDB v7, pg breaking changes, Elasticsearch 7→8 - StrictDB absorbs every driver update internally. You change nothing.

🔀

Database Migrations

Switch from MongoDB to PostgreSQL by changing one URI string. Your application code stays identical.

🔒

Permanent Guarantee

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.

Write once.
Run on any database.

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.

mongodb:// postgresql:// mysql:// mssql:// sqlite: https://
app.ts
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 languages. One API.

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.

MongoDB filters → any database
// 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
SQL → any database (incl. MongoDB)
// 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.

See SQL Mode in Action → Try the SQL Playground

Not an ORM. A smarter driver.

No models, no migrations, no magic. StrictDB is a unified database driver with safety rails and AI-first discovery tools.

🔍

Schema Discovery

AI agents explore your schema with describe() - field names, types, indexes, and example filters. No more hallucinated column names.

🛡

Safety Guardrails

Empty-filter deletes, unbounded queries, and accidental mass updates are blocked by default. Production-safe from day one.

🧪

Dry-Run Validation

Catch schema mismatches and bad fields before executing with validate(). Zero wasted database round-trips.

🔧

Self-Correcting Errors

Every error includes a .fix field with the exact corrective action. AI reads the fix and self-corrects - no stack-trace parsing.

📜

Operation Receipts

Every write returns a structured receipt - matched, modified, inserted, deleted counts plus duration. Never wonder what happened.

🤖

MCP Server

14 tools exposed via Model Context Protocol. Connect Claude, GPT, or any MCP-compatible agent for safe, guardrailed database access.

Built for AI agents.
Safe for production.

Every feature is designed so AI agents can discover schemas, validate queries, understand translations, and self-correct - without ever running dangerous operations.

01
Discover

Schema Discovery

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
// }
02
Validate

Dry-Run Validation

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' }
// ]}
03
Explain

Query Explanation

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'
// }
04
Self-Correct

Self-Correcting Errors

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

Guardrails that actually protect you.

Dangerous operations are blocked by default. Not warnings - hard blocks. Override only with explicit confirmation.

🚫

Mass Delete

deleteMany({}) would delete all documents

BLOCKED

Mass Update

updateMany({}) would update all documents

BLOCKED
🔍

No Filter Delete

deleteOne({}) would delete an arbitrary row

BLOCKED

Unbounded Query

queryMany() without a limit returns everything

BLOCKED
Override when you mean it
// This is blocked:
await db.deleteMany('logs', {});

// This is allowed (explicit intent):
await db.deleteMany('logs',
  { _id: { $exists: true } },
  { confirm: 'DELETE_ALL' }
);

Give your AI agent
safe database access.

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.

strictdb_describediscover
strictdb_validatevalidate
strictdb_explainexplain
strictdb_query_oneread
strictdb_query_manyread
strictdb_countread
strictdb_insert_onewrite
strictdb_insert_manywrite
strictdb_update_onewrite
strictdb_update_manywrite
strictdb_delete_onewrite
strictdb_delete_manywrite
strictdb_batchbatch
strictdb_statusstatus
npm install -g strictdb-mcp Works with Claude, GPT, and any MCP-compatible agent View strictdb-mcp on npm

Every write returns a receipt.

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
// }

Listen to everything.

Typed events for connections, operations, slow queries, guardrail blocks, and more.

connected disconnected reconnecting reconnected error operation slow-query guardrail-blocked shutdown
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}`);
});

What StrictDB is not.

No magic. No hidden complexity. Just a unified driver with safety rails.

Not an ORM

No models, no Active Record, no entity decorators, no migration files.

It's a driver, not a framework.

Not a Query Builder

No method chaining, no fluent API, no builder patterns.

Write filters. StrictDB translates them.

Not an Abstraction Layer

No lowest-common-denominator approach. Access the native driver with db.raw() anytime.

Full power when you need it.

StrictDB vs. the alternatives.

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

Everything else included.

📦

Batch Operations

Mix inserts, updates, and deletes in a single batch() call. Transactional when the backend supports it.

🕒

Auto Timestamps

Automatic createdAt and updatedAt injection on writes. Toggle on with a single config flag.

🔄

Auto Reconnection

Exponential backoff with configurable max attempts, delays, and multiplier. Your app stays alive.

🔒

Transactions

Full transaction support across MongoDB (replica set), PostgreSQL, MySQL, MSSQL, and SQLite.

🧹

Input Sanitization

SQL column whitelisting, ES internal field blocking, regex complexity limits. Bad input never reaches your database.

🎯

Zod Validation

Register Zod schemas for collections. StrictDB generates DDL for SQL backends and validates all writes automatically.

Start building with StrictDB.

One install. One API. Six databases. AI-ready from the first line.

npm install strictdb