CollectionQuery<T> class
An immutable, typed query over a Collection, built by chaining where, orderBy, limit, and startAfter, and executed with get or page.
Every clause validates at build time against the collection's
MergeStrategy: the operators must fit the field's CrdtType (contains
needs an OrSet, comparisons need an orderable field), so a misdirected
query throws ArgumentError instead of silently returning nothing.
Execution runs in the storage engine — on the SQLite engine as SQL, using
the indexes declared via indexedFields — and only the matching documents
are decoded. Results are ordered by (order-by value, document id);
documents that lack the order-by field sort first (last when descending).
That order is total and engine-independent, which makes page safe for
infinite scroll: pages are disjoint and gap-free, and a cursor points at
the same boundary after a reopen and on every converged device.
final page = await items
.query()
.where('done', isEqualTo: false)
.orderBy('createdAt', descending: true)
.limit(20)
.page();
// Later: .startAfter(page.nextCursor!) for the next page.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
get(
) → Future< List< T> > - Runs the query and returns the matching documents.
-
limit(
int n) → CollectionQuery< T> -
Caps the number of returned documents at
n(which must be positive). -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
orderBy(
String path, {bool descending = false}) → CollectionQuery< T> -
Orders the results by the field at
path(then by document id, as a tiebreak). Documents without the field sort first — last whendescending. -
page(
) → Future< QueryPage< T> > - Runs the query and returns the matching documents plus the cursor for the next page.
-
startAfter(
QueryCursor cursor) → CollectionQuery< T> -
Resumes after
cursor, the position handed back by a previous page of the same query (same predicates and order). -
toString(
) → String -
A string representation of this object.
inherited
-
watch(
) → Stream< List< T> > - Watches the query: emits its result after the initial load, then again whenever a change — local or synced — alters the result's contents or order.
-
where(
String path, {Object? isEqualTo = _unset, Object? isGreaterThan = _unset, Object? isLessThan = _unset, List< Object?> ? isIn, Object? contains = _unset}) → CollectionQuery<T> -
Adds one comparison on the field at
path; clauses combine with AND.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited