Core API

Query Builder

Fluent index filtering with equals, ranges, and counts.

Overview

The query builder is returned by where(indexName) on any store. It lets you chain index filters before executing a query with toArray(), first(), or count(). Use it for reusable lookups and range queries when getAllFromIndex() is too rigid.

Usage

query-builder.ts

QueryBuilder API

NameTypeDescription
equals(value) QueryBuilder<T>Match a single index value
between(lower, upper, lowerOpen?, upperOpen?) QueryBuilder<T>Match values within an index range
above(value) QueryBuilder<T>Match values greater than the given value
aboveOrEqual(value) QueryBuilder<T>Match values greater than or equal to the given value
below(value) QueryBuilder<T>Match values less than the given value
belowOrEqual(value) QueryBuilder<T>Match values less than or equal to the given value
toArray() Promise<T[]>Resolve all matching records
first() Promise<T | undefined>Resolve the first matching record
count() Promise<number>Count the matching records

Notes

QueryBuilder works on both core stores and reactive stores, since createReactiveDB() forwards the same query API through ReactiveStore.

Use getAllFromIndex() when you only need a single one-shot index lookup. Use where() when you need reusable filters or range operators.