Skip to content

Coming from MongoDB

Most code written for the MongoDB Node.js driver works after changing how you connect:

import { MongoClient } from 'mongodb';
const client = new MongoClient(process.env.MONGODB_URI);
const db = client.db('crm');
import { DriveDB } from '@faeizfurqan/drivedb';
const client = new DriveDB(process.env.DRIVEDB_URL);
const db = client.db(); // a connection string opens one database
Feature Status
find, findOne, cursors (sort, skip, limit, project, toArray, for await) ✅
insertOne, insertMany, updateOne, updateMany, replaceOne, deleteOne, deleteMany ✅
findOneAndUpdate, findOneAndDelete ✅ (findOneAndReplace: use replaceOne + findOne)
bulkWrite ✅ always ordered and all-or-nothing
countDocuments, estimatedDocumentCount, distinct ✅
Query operators ✅ comparison, logical, element, $regex, arrays
Update operators ✅ including upserts and $setOnInsert
Aggregation pipelines ✅ except $out and $merge
$lookup ✅ by collection API name; plus populate for link fields
createIndex with unique: true ✅ single field
Other indexes Accepted, no effect (queries run in memory)
Change streams (watch) ✅ insert, update and delete events; no resume tokens
ObjectId Ids are strings ("r3kq8z1m2x7v"), or strings you choose
Date values Accepted; stored and returned as ISO strings
Transactions and sessions ❌ use bulkWrite or findOneAndUpdate (each call is atomic)
$text, geospatial, $where, $function ❌
GridFS, capped collections, time series ❌
Multiple databases per client One per connection string
  • Documents follow a table. Each field has a type, and values are checked against it (ValidationError). New fields are added on insert, so you can start without a schema; set types with createCollection or in the app.
  • Nested data lives in JSON fields. Dot paths work in filters, updates and projections.
  • Empty means missing. Setting a field to null or '' empties it, and empty fields are left out of documents.
  • Error codes are names ('DuplicateKey') rather than numbers (11000).
  • Sizes. Databases are meant for up to tens of thousands of records (the app warns at 25,000), with 1 MB per request and 1,000 documents per page.

Made by Faeiz Furqan