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 where clauses ({field, op, param}, as the config and the manifest carry them) to params, then adds the owner clause FFX injects into an owner-bound query (its list rule is owner): 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 under order, 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
a and b compared by their UTF-8 bytes, as FFX's indexes and ids sort.
normalizeWireTimestamp(String value) → String
An RFC 3339 UTC Z timestamp in FFX's canonical form, exactly six fraction digits (schema normalizeTimestamp, 18 §10): the form every stored timestamp has, and every timestamp param once FFX binds it. value must already be such a string, with up to nine fraction digits.
queryFieldValue(Map<String, Object?> doc, String path) → Object?
The value at path in doc: 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 doc satisfies every clause. notEq and notIn never 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.ts compareScalars): 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}, direction ascending or descending). Throws FormatException for any other shape.
queryOrderPresent(Iterable<QueryOrder> order, Map<String, Object?> doc) → bool
Whether FFX's answer to a query ordered by order can hold doc at all: the query's index has no entry for a record whose orderBy field is absent or null (spanner-store computeEntryKeys), 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<String, Object?>)> rows, Iterable<QueryOrder> order) → void
Sorts (id, doc) rows in place by order with 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.