Node.js quickstart
By the end of this page you will have a running Node.js script that creates an end-to-end encrypted document store, writes a todo, and reads it back — all in under 5 minutes.
1) Install
Create a new project (or use an existing one) and install MindooDB. Node.js 20+ is required.
npm init -y
npm install mindoodb 2) Create index.mjs
Paste the following into index.mjs.
The createTenant call generates all cryptographic keys (admin signing key,
user signing key, encryption keys, tenant key) and registers the first user
in a single step. After that, we open a database and create a document — every
change is automatically signed and encrypted.
import {
BaseMindooTenantFactory,
InMemoryContentAddressedStoreFactory,
} from "mindoodb";
async function main() {
const storeFactory = new InMemoryContentAddressedStoreFactory();
const factory = new BaseMindooTenantFactory(storeFactory);
// One call creates admin + user keys, KeyBag, and directory
const { tenant, adminUser, appUser, keyBag } =
await factory.createTenant({
tenantId: "my-first-tenant",
adminName: "cn=admin/o=demo",
adminPassword: "admin-password",
userName: "cn=alice/o=demo",
userPassword: "user-password",
});
// Open a database and create a todo document
const db = await tenant.openDB("todos");
const todo = await db.createDocument();
await db.changeDoc(todo, async (d) => {
const data = d.getData();
data.title = "Buy milk";
data.done = false;
});
// Read it back
const ids = await db.getAllDocumentIds();
const loaded = await db.getDocument(ids[0]);
console.log("Loaded todo:", loaded.getData());
}
main(); 3) Run
node index.mjs Expected output:
Loaded todo: { title: 'Buy milk', done: false } What's next?
You have a single-user setup. The real power of MindooDB is multi-user collaboration with end-to-end encryption — where the server never sees plaintext.