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/local-development.md.

Local development and testing

Silt lets you run supported MongoDB application code without starting a database service. Use a persistent file during development and an isolated database for each test.

Develop with a local file

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

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

Pass db to application code as you would a MongoDB database handle. Keep the client open while the application runs, then await client.close() on shutdown. Reopening the same file retains its documents and indexes.

Keep development database files and their -wal and -shm companions out of source control.

Isolate tests

On Node, :memory: creates a database owned by that client. A new client gives each test a fresh fixture.

import assert from 'node:assert/strict';
import test from 'node:test';
import { MongoClient } from '@silt-db/mongodb';

test('saves a task', async (t) => {
  const client = new MongoClient(':memory:', { dbName: 'app' });
  t.after(() => client.close());
  const tasks = client.db().collection('tasks');

  await tasks.insertOne({ _id: 'task-1', done: false });
  assert.equal((await tasks.findOne({ _id: 'task-1' })).done, false);
});

Use a unique temporary file instead when testing persistence across reopen. Applications can accept a database or collection in their setup code, letting the same business logic run against Silt or MongoDB.

What these tests establish

Silt tests your application's supported JSON workload. Keep real MongoDB integration checks for code that also targets MongoDB, especially dependencies on BSON, server features, concurrency details, or errors. The compatibility reference lists those boundaries.