Read
You can read data using find() to fetch multiple documents, and get() to fetch a single document by ID.
find() maps to GET /:collection/docs andget() maps to GET /:collection/docs/:id.
🔹 find()
Use this to query a collection and retrieve multiple documents.
const users = await db.users.find({
filter: { isAdmin: true },
sort: "-createdAt",
limit: 10,
});Advanced operators are supported for numeric/date-like fields:
const latest = await db.users.find({
filter: {
loginCount: { gte: 10 },
},
sort: "-updatedAt",
limit: 20,
});Options
| Option | Type | Description |
|---|---|---|
filter | Partial<Schema> | Filters by matching fields |
sort | string | Sort by a field (use - prefix for descending) |
limit | number | Max number of results to return |
offset | number | Skips N number of results (for pagination) |
🔸 get()
Use this to fetch a single document by its ID.
const user = await db.users.get("user_abc123");You can also select specific fields:
const user = await db.users.get("user_abc123", {
select: { name: true, email: true },
});Missing document IDs return a 404 from the API and throw an error in the SDK.
Error Responses
// 404 — document not found
{ "error": "Document not found" }
// 401 — invalid API key
{ "error": "Missing or invalid Authorization header" }
// 400 — invalid collection name
{ "error": "Invalid collection name: 'my collection'. Use letters, numbers, underscores, and hyphens only." }