Indexes
Single-field indexes are automatically generated, but multi-field compound indexes need to be added by the DB admin before dirs can be accessed with complex queries.
Add an index.
await db.addIndex([ [ "age" ], [ "height", "desc" ] ], "people")
Get indexes of a dir.
const indexes = (await db.stat("people")).indexes ?? []
Remove an index.
await db.removeIndex([ [ "age" ], [ "height", "desc" ] ], "people")
_id_
__id__
is reserved to auto-index doc ids. __id__
field will not be indexed, and __id__
cannot be used in multi-field indexes.
You can, however, use __id__
to get a dir in descending order sorted by doc id.
await db.get("people", ["__id__", "desc"], 5)