query library
Named-query predicate and order over plain maps (04 §3.5): the where operators, the owner clause and FFX's index order, shared by the app SDK (local data, 5.5–5.6) and the emulator.
Constants
-
queryOperators
→ const Set<
String> - The where operators (03 §5.2), as the config and the local-data manifest name them. A clause with any other operator cannot be run on a device.
Functions
-
bindQueryClauses(
Iterable< Object?> where, Map<String, Object?> params, {String? ownerField, String? endUserId, Map<String, Object?> ? paramTypes}) → List<QueryClause> -
Binds a query's
whereclauses ({field, op, param}, as the config and the manifest carry them) toparams, then adds the owner clause FFX injects into an owner-bound query (its list rule isowner):ownerField == endUserId. Throws FormatException for a clause that is not that shape or names an operator outside queryOperators, so a caller can tell a query it cannot run from one that matches nothing. -
compareQueryRows(
(String, Map< String, Object?> ) a, (String, Map<String, Object?> ) b, Iterable<QueryOrder> order) → int -
The order of two
(id, doc)rows underorder, ties broken by id. -
compareQueryValues(
Object? a, Object? b) → int - Index order of two field values: null first; numbers numerically; strings by UTF-8 bytes; booleans false before true; values of different types by type rank (boolean, number, string, then anything else).
-
compareUtf8(
String a, String b) → int -
aandbcompared by their UTF-8 bytes, as FFX's indexes and ids sort. -
normalizeWireTimestamp(
String value) → String -
An RFC 3339 UTC
Ztimestamp in FFX's canonical form, exactly six fraction digits (schemanormalizeTimestamp, 18 §10): the form every stored timestamp has, and every timestamp param once FFX binds it.valuemust already be such a string, with up to nine fraction digits. -
queryFieldValue(
Map< String, Object?> doc, String path) → Object? -
The value at
pathindoc: a top-level field, or one level into a map (style.color); null when absent. -
queryMatches(
Iterable< QueryClause> clauses, Map<String, Object?> doc) → bool -
Whether
docsatisfies every clause.notEqandnotInnever match a null value; an operator outside queryOperators never matches. A range clause holds only between two numbers or two strings, as FFX re-checks it (query-engine.tscompareScalars): never for a null or absent value, a null param, booleans, or values of different types. -
queryOrderFrom(
Iterable< Object?> orderBy) → List<QueryOrder> -
Reads a query's
orderBy({field, direction}, directionascendingordescending). Throws FormatException for any other shape. -
queryOrderPresent(
Iterable< QueryOrder> order, Map<String, Object?> doc) → bool -
Whether FFX's answer to a query ordered by
ordercan holddocat all: the query's index has no entry for a record whose orderBy field is absent or null (spanner-storecomputeEntryKeys), so FFX never lists it, whatever the where clauses say. A device deciding which rows a list shows checks this beside queryMatches. -
sortQueryRows(
List< (String, Map< rows, Iterable<String, Object?> )>QueryOrder> order) → void -
Sorts
(id, doc)rows in place byorderwith the id tiebreak.
Typedefs
- QueryClause = ({String field, String op, Object? value})
-
One where clause bound to its value: the field path (a declared field,
or
map.subfield), the operator and the value to compare with. - QueryOrder = ({bool descending, String field})
- One orderBy key.