For AI agents: the complete documentation index is available at https://silt-db.dev/llms.txt, the full documentation bundle is available at https://silt-db.dev/llms-full.txt, and this page is available as Markdown at https://silt-db.dev/guide/mongodb.md.

Use MongoDB code

Silt can replace MongoDB for code that uses its supported JSON collection API. The main change is the client import and initialization.

Change the client

A MongoDB application opens a server connection:

import { MongoClient } from 'mongodb';

const client = new MongoClient('mongodb://localhost:27017');
await client.connect();
const db = client.db('app');

With Silt, open a SQLite file:

import { MongoClient } from '@silt-db/mongodb';

const client = new MongoClient('./app.sqlite', { dbName: 'app' });
await client.connect();
const db = client.db('app');

Code using supported methods on db and its collections stays the same:

export async function listOpenTasks(db) {
  return db.collection('tasks').find({ done: false }).sort({ priority: -1 }).toArray();
}

Use one long-lived client for the application and close it during shutdown. The configured dbName names the single database represented by that file. Another name is rejected; use another file for another database.

Use the MongoDB documentation

Silt follows MongoDB query semantics for supported operators. Use the official guides for syntax and the Silt references to check coverage.

TopicOfficial documentationSilt differences
Filters and query languageMongoDB Query APIQuery support
Collection methods and cursorsNode driver and cursorsDriver API and options
Aggregation and joinsAggregationPipelines and expressions
UpdatesUpdate operatorsUpdate support
IndexesIndexesIndex catalog
TransactionsTransactionsSessions and transactions

Check application dependencies

This is an in-process JavaScript API replacement, not a MongoDB network endpoint. A library can use Silt when it accepts an injected compatible Db or Collection and stays within the supported API. A library that opens its own MongoDB connection, requires BSON classes, or depends on driver internals needs additional integration.

Silt does not currently claim drop-in compatibility with every MongoDB library, including Mongoose. Check the compatibility reference against the methods, types, and options your code actually uses.

For runtime choices, continue with Node deployment or Expo.