Queries

Building a query

app.db.collection("orders")
  .where("status", "==", "paid")
  .where("total", ">=", 1000)
  .where("city", "in", ["Lahore", "Karachi"])
  .orderBy("createdAt", "desc")
  .limit(25).page(2)
  .get()

Operators

OpMeaning
== !=equality (numbers, strings, booleans)
> >= < <=comparison
invalue in array (≤ 30 items)
containssubstring (case-insensitive) — or array field contains value
startsWithprefix match
likeSQL LIKE pattern (% wildcard)

Nested fields use dot paths: where("address.city", "==", "Mansehra"). Special fields: id, owner, createdAt, updatedAt.

Pagination

limit(n) ≤ 500, offset(n) or page(p). Response includes total and hasMore.

REST equivalent

GET /v1/{pid}/db/orders?where=[["status","==","paid"],["total",">=",1000]]&orderBy=createdAt&dir=desc&limit=25&offset=25
# or simple form
GET /v1/{pid}/db/orders?status=paid&total[gte]=1000

Performance

Queries run on JSON fields inside SQLite (json_extract). Up to ~100 k docs per collection performs fine for typical apps. Keep documents small; prefer several collections over huge arrays inside one doc.


Was this page helpful? Tell us. · Download SDK