Skip to main content

Query & update language

LioranDB’s embedded query engine supports:

Queries

Queries are plain objects. Keys can be dot-paths (example: "profile.age").

Equality

{ email: "a@b.com" }

Operators

For a field x, these operators are supported:

  • $gt, $gte
  • $lt, $lte
  • $ne, $eq
  • $in (array membership)

Examples:

{ age: { $gte: 18, $lt: 65 } }
{ status: { $in: ["active", "trial"] } }

Functional queries

You can also pass a function:

(doc) => doc.qty > 0 && doc.sku?.startsWith("A")

Updates

Updates can be:

Operator updates

$set

{ $set: { "profile.name": "New Name" } }

$inc

{ $inc: { attempts: 1 } }

Replacement/merge updates

If the update object contains no $ keys, it’s treated as a shallow merge:

{ status: "active", plan: "pro" }

Upserts

updateOne(filter, update, { upsert: true }) inserts a new document if nothing matches.