Getting started
Install
Section titled “Install”The TypeScript SDK, for web apps, Node and agents written in TypeScript:
npm install @nocentraldb/sdkThe Rust SDK:
cargo add nocentraldbThe command-line tool ncdb builds model.lock.json from your schema. How it is distributed is not decided yet.
Describe the model
Section titled “Describe the model”import { nc } from "@nocentraldb/sdk";
export const model = nc.model({ tasks: nc.collection( { title: nc.string(), status: nc.oneOf(["open", "in_progress", "done"]), priority: nc.int(), }, { indexes: { byStatusPriority: nc.index(["status", "priority"], { equal: 1 }), }, }, ),});Then build the lock that the Rust core and both SDKs read:
ncdb model buildOpen a database and write
Section titled “Open a database and write”const db = await nc.open({ model, lock, relay: "wss://relay.example.com" });const project = await db.spaces.create();
await project.write((tx) => { tx.create(model.tasks, { title: "Write the README", status: "open", priority: 1, });});A write is designed to resolve once the change is in the local log and the view, before the relay has it. Read on in Concepts.