drift Docs
Start
What is Drift?
The tour, if you are new here.
Why Drift?
The case for a smaller cloud.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, five unit prices, two rules.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Accounts, tokens and scopes.
Security
Boundaries, sandboxing and hardening.

Backbone NoSQL

JSON document collections. A write is an upsert on the document's own _id, and the platform assigns the storage key.

Document identity: _key and _id

_key is the platform's. It is injected into every document as it is stored, formatted <counter>_<unix-nanos>, and it is what read and delete address. Nothing returns it at write time, so read it out of a list result.

_id is yours. Supply one and a second write with the same _id replaces the first. Omit it and every write adds a row. An _id outside the index charset below is not indexed, so the upsert silently becomes an append.

Method Takes
Insert(doc)The document. Returns an empty string on a deployed slice, because the write endpoint answers with text, not a key.
Read(key)A _key.
Delete(key)A _key.
Get(id)An _id, resolved through the index.
List(filter)One field/value pair. See below.
Drop()Nothing. Deletes the collection and every document in it.
Go
// _id makes the write idempotent; Get resolves it through the index
drift.Backbone.NoSQL.Collection("users").Insert(map[string]any{
    "_id":  "alice",
    "name": "Alice",
    "role": "admin",
})
alice,  _ := drift.Backbone.NoSQL.Collection("users").Get("alice")
admins, _ := drift.Backbone.NoSQL.Collection("users").List(map[string]string{"role": "admin"})

Filtering

A filter reaches only what the blind index holds. At write time the platform indexes top-level scalar fields: strings, numbers, booleans. Maps, arrays and nulls are skipped, so a nested field cannot be filtered at all.

The field name and the value's string form must each match [A-Za-z0-9_][A-Za-z0-9._-]{0,254} with no ... That rules out an email address (the @), an ISO timestamp (the :), and anything containing a space. Such a value is never indexed, and filtering on one answers 400 invalid field or value name rather than an empty list.

One pair is honoured.

List sends every entry of the map, and the slice reads the first field and the first value and ignores the rest. There is no AND across fields, and map iteration order decides which one wins. Filter on one indexed field and narrow the rest in your own code.

Result limits

list returns 100 documents when no limit is given and clamps any limit to 1–1000. The SDKs' List sends no limit at all, so a collection of 5,000 documents yields the first 100 with nothing in the response to signal the truncation. The CLI's --limit defaults to 100 and obeys the same ceiling.

NoSQL from the CLI

Shell
drift backbone nosql write --collection users --data '{"_id":"alice","name":"Alice","role":"admin"}'
drift backbone nosql list  --collection users --field role --value admin --limit 500
drift backbone nosql read  --collection users --key 7_1754308800000000000   # a _key taken from `list`
drift backbone nosql drop  users

Collections can be seeded at deploy time from a JSONL file; see the Driftfile.

Give a collection a ttl in the Driftfile and the platform reaps documents whose last write is older than it. The clock resets on every write, so only stale documents are deleted. There is no undo. Omit it and documents are kept forever.