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

OptionTypeDescription
filterPartial<Schema>Filters by matching fields
sortstringSort by a field (use - prefix for descending)
limitnumberMax number of results to return
offsetnumberSkips 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." }