Getting started
Install the embedded database:
npm i @liorandb/core
Create a database, write a document, read it back:
- TypeScript
- JavaScript
import { LioranManager } from "@liorandb/core";
const manager = new LioranManager({
// optional: where databases live on disk
// rootPath: "./data",
});
const db = await manager.db("app");
const users = db.collection<{ _id?: string; email: string; plan: "free" | "pro" }>("users");
await users.insertOne({ email: "a@b.com", plan: "free" });
const found = await users.findOne({ email: "a@b.com" });
console.log(found);
await manager.close();
import { LioranManager } from "@liorandb/core";
const manager = new LioranManager({
// optional: where databases live on disk
// rootPath: "./data",
});
const db = await manager.db("app");
const users = db.collection("users");
await users.insertOne({ email: "a@b.com", plan: "free" });
const found = await users.findOne({ email: "a@b.com" });
console.log(found);
await manager.close();
What gets created on disk?
- A root folder containing one folder per database name.
- Each collection is stored in its own directory (file-based storage).
By default, @liorandb/core uses:
process.env.LIORANDB_PATHif set, otherwise~/LioranDB/db(created automatically)
If you want a project-local folder, pass rootPath to new LioranManager({ rootPath }).