Getting started
- Sign up. You get a team and a first database,
main, on the Free plan. - In the console, make a key for the database: admin to create collections, write or read for your app.
- Install an SDK and connect to
https://api.twilightdb.comwith the key as the bearer token.
Install an SDK
The SDKs (TypeScript, Go, Python, Swift, Java, Kotlin, Dart) aren't on package registries yet. Until they are,
ask support@twilightdb.com for access to the source and install from it; the TypeScript one is
@twilightdb/client.
A first program
// Issue is your protobuf type: every field is checked, no migrations
const db = new TwilightDB({ baseUrl, token: process.env.TWILIGHTDB_TOKEN }).database("tdb-…-main")
const issues = db.collection("issues", IssueSchema)
// live: the first page, then only what changed, never a re-sent list
for await (const ev of db.watchQuery(issues, { filters: [where("status", "==", Status.OPEN)] }))
render(ev.upserted, ev.removed)
// exact: strictly serializable, retried for you if another write got there first
await db.transaction(async (tx) => {
const sprint = await tx.get(sprints, id)
tx.put(sprints, id, { ...sprint!.value, committed: sprint!.value.committed + points })
})
What to read next
- Collections and types: every collection has a protobuf type, stored with it. Change a type by adding fields; removing one goes through a proposal that checks stored records and live indexes first.
- Queries:
where(field, op, value)with== != < <= > >= in, an index for each filter-and-sort shape, cursors for pages. - Live:
watchQuery,watchRecord,watchView(views keep counts and sums incrementally), andchangesfor the change stream in commit order. - Transactions:
db.transaction(async (tx) => …)is optimistic and retried; up to 10,000 writes and 10 MB per commit. - Access from browsers: per-collection read and write rules over your users' sign-in tokens, so a browser can talk to the database directly.
- Webhooks and export: signed webhooks in commit order, Parquet and Iceberg export.
The full guide is being published. Questions: support.