Migrating from MongoDB
Complete guide to migrating from MongoDB to Toolless
Why Migrate?
Toolless is ideal when you want to:
- Eliminate database infrastructure
- Simplify development setup
- Use file-based storage
- Reduce operational overhead
Export from MongoDB
Using mongoexport
mongoexport --db mydb --collection users --out users.json --jsonArrayFor large collections:
mongoexport --db mydb --collection users --out users.ndjsonUsing mongodump
mongodump --db mydb --out ./backupImport to Toolless
toollessdb import mydb users users.jsonOr via API:
import { createClient } from "toollessdb";
import fs from "fs";
const client = createClient({ path: "./data" });
const db = client.db("mydb");
const users = db.collection("users");
const data = JSON.parse(fs.readFileSync("users.json", "utf8"));
await users.insertMany(data);API Comparison
| MongoDB | Toolless | Notes |
|---|---|---|
insertOne | insertOne | Identical |
insertMany | insertMany | Identical |
find | find | Identical |
findOne | findOne | Identical |
updateOne | updateOne | Identical |
updateMany | updateMany | Identical |
deleteOne | deleteOne | Identical |
deleteMany | deleteMany | Identical |
countDocuments | countDocuments | Identical |
aggregate | Not supported | Use JavaScript |
transactions | Not supported | Single-doc atomic |
Query Operators
Most operators are supported:
// These work the same
find({ age: { $gte: 18 } });
find({ $or: [{ a: 1 }, { b: 2 }] });
find({ tags: { $in: ["a", "b"] } });
find({ name: { $regex: /alice/i } });Update Operators
// These work the same
updateOne({ _id: "123" }, { $set: { name: "Alice" } });
updateOne({ _id: "123" }, { $inc: { count: 1 } });
updateOne({ _id: "123" }, { $push: { tags: "new" } });Code Migration
Before (MongoDB)
import { MongoClient } from "mongodb";
const client = new MongoClient("mongodb://localhost:27017");
await client.connect();
const db = client.db("mydb");
const users = db.collection("users");After (Toolless)
import { createClient } from "toollessdb";
const client = createClient({ path: "./data" });
const db = client.db("mydb");
const users = db.collection("users");Limitations
Features not available in Toolless:
- Aggregation pipelines
- Multi-document transactions
- Change streams
- Sharding
- Replication
Migration Checklist
- Export data from MongoDB
- Import to Toolless
- Update connection code
- Test queries work correctly
- Remove aggregation pipelines
- Replace transactions with application logic
- Test thoroughly
- Deploy and monitor