Lex
A lex query selects which properties of a node are returned. It can be passed to get(), next(), user.get() and on(), and without one the full node is returned.
A lex query applies to the node at the end of the chain, so a request with one can't be followed by other functions. The result can be awaited or passed to a callback.
Format
The format is the same as GunDB's "." property. A string makes an exact match on a key:
const item = await holster.get("item", {".": "property"})An object makes a range or prefix match, using:
Option | Matches |
|---|---|
| Keys that start with the given prefix. Can't be combined with the other options. |
| Keys lexically greater than or equal to the given value. |
| Keys lexically less than or equal to the given value. |
These queries all match a property named key:
{".": "key"}
{".": {"*": "k"}}
{".": {">": "j", "<": "m"}}Example
Prefix matches work well with keys that sort in a useful order, such as posts whose keys start with a date:
await holster.get("posts").put({
"2026-09-30-last-day-of-september": {title: "Last day of September"},
"2026-10-01-hello-world": {title: "Hello world"},
"2026-10-15-mid-month-update": {title: "Mid month update"},
})
const october = await holster.get("posts", {".": {"*": "2026-10"}})
console.log(Object.keys(october))
// ["2026-10-01-hello-world", "2026-10-15-mid-month-update"]
// With a callback.
holster.get("posts", {".": {"*": "2026-10"}}, console.log)The matching posts are returned in full, including any nested objects, so a lex query is also a way to avoid reading posts that aren't needed.
GunDB's paging option, "%", isn't supported.