Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mainser/cindel/llms.txt
Use this file to discover all available pages before exploring further.
CindelQuery<T> is the typed query builder that every generated collection helper builds on. You obtain a CindelQuery<T> by calling db.collection.all(), db.collection.where(), or db.collection.filter(), and then refine it by chaining modifiers — sort, distinct, offset, limit, and filter predicates — before executing a terminal operation. Query objects are immutable: every modifier method returns a new CindelQuery<T> with the requested change applied, leaving the original untouched. At execution time, Cindel selects the most efficient path available — native binary plans on MDBX, native SQL on the SQLite backends, or Dart-side evaluation as a fallback.
Terminal Read Operations
Terminal operations execute the query and return a result. They must be called last in any chain.findAll
findFirst
null if no documents match. Equivalent to calling findAll() and taking the first element, but expressed more clearly in code.
count
count delegates to a native counting path and avoids deserializing the matching documents.
Terminal Mutation Operations
deleteAll
0.
deleteFirst
true if a document was deleted, or false if no documents matched. Respects the current sort order to determine which document is “first”.
updateAll
changes to every document matching the query and returns the number of documents updated. The keys in changes are persisted field names as they appear in the generated schema.
updateAll requires a native query plan — attempting to call it without one throws an UnsupportedError. The id field cannot be updated and raises an ArgumentError if included in changes.
Supported value types: null, bool, int, double, String, List, and Map.
Field names mapped to their new values. Supports
null, bool, int,
double, String, List, and Map. The id field cannot be updated.updateFirst
changes to the first document matching the query. Returns true if a document was updated, or false if no documents matched. Like updateAll, this requires a native query plan and does not support updating the id field.
Field names mapped to their new values. The id field cannot be updated.
Modifiers
Modifiers are chained before a terminal operation. Each returns a newCindelQuery<T>.
sortBy / sortByDesc (generated)
Generated sort helpers are named after indexed fields — for example, sortByName() for ascending order and sortByNameDesc() for descending. Under the hood they call CindelQuery.sortBy(field, order: ...).
You can also call sortBy directly on any query with a raw field name:
thenBy for secondary and tertiary ordering:
offset
count results after filtering, sorting, and distinct are applied. Must be non-negative.
Number of results to skip. Must be
≥ 0.limit
count results after offset is applied. Must be non-negative.
Maximum number of results to return. Must be
≥ 0.Pagination example
distinctBy / distinctByFields
field, or for each distinct tuple of fields. De-duplication is applied after filtering and sorting, so the sort order determines which document is kept when multiple documents share the same distinct key.
whereMatches
predicate. When the predicate is a top-level equality check on an indexed field and no other filter or source is already set, Cindel automatically promotes the query to an index-backed source.
Use CindelFilter.field(name) or CindelFilter.path(parts) to build predicates, and CindelFilter.all, CindelFilter.any, and CindelFilter.not to compose them.
A filter predicate built with
CindelFilter helpers. ANDed with any
existing filter on the query.Property Projections
Cindel exposes two projection APIs. Single-field projections useproperty<R>(field) (or generated helpers such as .nameProperty()) and return a CindelPropertyQuery<T, R>. Multi-field projections use properties(fields) and return a CindelPropertiesQuery<T>. Both avoid deserializing fields you do not need.
property / CindelPropertyQuery
decode callback to convert raw document values to a typed R. When the backing query has a native plan on MDBX, the projection and aggregates run entirely in native code.
findAll (property projection)
findFirst (property projection)
null if no documents match.
count (property projection)
Aggregates
Aggregates operate over the projected field values of all matching documents, ignoringnull values.
| Method | Return type | Description |
|---|---|---|
max() | Future<R?> | Largest non-null value. |
min() | Future<R?> | Smallest non-null value. |
sum() | Future<num?> | Sum of numeric values. Returns null when all values are null. |
average() | Future<double?> | Mean of numeric values. Returns null when all values are null. |
sum and average require the projected field to hold numeric values at
runtime. Calling them on a non-numeric field throws CindelQueryError.
max and min require the projected type to be Comparable.properties / CindelPropertiesQuery
CindelPropertiesQuery<T>. Each result is a CindelDocument (a Map<String, Object?>) containing only the requested keys.
findAll (multi-field projection)
findFirst (multi-field projection)
null if no documents match.
Reactive
watch
fireImmediately: false to suppress the initial event and only receive subsequent changes.
How often the underlying change watcher polls for updates. Defaults to the
global
defaultCindelWatchPollInterval constant.When
true (the default), the stream emits the current query result
immediately on subscription before listening for further changes. Set to
false to receive only subsequent change events.watchLazy
void event when the query result may have changed, without re-executing the query or deserializing any objects. Use this when you manage the read yourself and want to avoid the cost of automatic re-execution on every change.
How often the underlying change watcher polls for updates.
When
true, the stream emits one event immediately on subscription.Composition Helpers
Composition helpers let you build dynamic queries withoutif branches. They are available on generated filter builders and proxy through to CindelQuery methods of the same name.
optional
builder to the query only when condition is true. When condition is false, the query is returned unchanged. This is the idiomatic way to add a filter only when a search term or toggle is present.
When
true, builder is applied. When false, the query is unchanged.A callback that receives the current query and returns a modified query.
May only add filter predicates — sort, distinct, window, or source changes
are rejected.
anyOf
builder once for each item in items and ORs the generated predicates together. A document matches if it satisfies the predicate produced by any one item. If items is empty, the query matches nothing.
Values to iterate. An empty iterable makes the query match nothing.
A callback invoked once per item. Returns a query with one additional
filter predicate. May only add filters — other modifications are rejected.
allOf
builder once for each item in items and ANDs the generated predicates together. A document matches only if it satisfies the predicate produced by every item. If items is empty, the query is returned unchanged.
Values to iterate. An empty iterable leaves the query unchanged.
A callback invoked once per item. Returns a query with one additional
filter predicate. May only add filters — other modifications are rejected.