Quick Start
Get up and running with ctrodb in under a minute
Create a database, define a schema, and start reading and writing data.
1. Create a database
import { Database } from "ctrodb"
const db = new Database({
schema: {
version: 1,
collections: {
todos: {
fields: {
title: { type: "string", required: true },
done: { type: "boolean", default: false },
},
},
},
},
})
2. Connect
await db.connect()
This initializes the storage adapter. By default it picks IndexedDB in browsers and memory in Node.
3. Insert data
const todos = db.collection("todos")
const task = await todos.create({
title: "Learn ctrodb",
})
console.log(task.id) // 1
console.log(task.title) // "Learn ctrodb"
4. Query data
const results = await todos
.query()
.where("done", "==", false)
.fetch()
console.log(results.length) // 1
5. Update and delete
task.title = "Master ctrodb" // warns — use update()
await task.update({ done: true })
await task.delete()
Read the Database docs for details.
How is this guide?
Last updated on Jun 20, 2026