Build a predicate, then pass it to db.query directly or through Query.select. Every builder is O(1): it creates an AST
node and matches nothing until the query runs.
Predicate for property to be in the provided array, or in the set of values projected
from a subquery's results (an uncorrelated col IN (SELECT property FROM ...) semi-join —
see Query.project). The subquery may target a different scope than the parent query; it
is resolved once at execution time.
@param ― values - Values to check against, or a single subquery projection.
@performance ― O(1); builds a filter AST node without matching anything.
@performance ― Async; executes the full query (index plus working set) on every call, not cached; O(n) in the data
the executor examines, not in the result count.
childOf matches the children of one or more objects, and their children in turn unless transitive is false. It takes
objects or references, and reads a reference’s URI without loading the target.
Filter objects that are children of the specified parent(s).
Accepts ECHO objects, Refs, or arrays of either.
Refs are resolved to DXNs without loading; objects use
Obj.getURI
.
With transitive=true (default), also matches grandchildren and beyond.
@performance ― O(k) in the number of parents; refs are read by URI without loading.
Filter objects that are children of the specified parent(s).
Accepts ECHO objects, Refs, or arrays of either.
Refs are resolved to DXNs without loading; objects use
Obj.getURI
.
With transitive=true (default), also matches grandchildren and beyond.
@performance ― O(k) in the number of parents; refs are read by URI without loading.
childOf(
const launch: Event
launch, {
transitive?: boolean | undefined
Whether to match transitively (grandchildren, etc.). Defaults to true.
changes selects the changes to some objects, or to every object in the space, instead of the objects. Order them by
time, or count them with an aggregate.
1
import {
import Filter
Filter,
import Query
Query } from'@dxos/echo';
2
3
const
const history: Query.Query<{
readonly key: string;
readonly source: "document" | "feed";
readonly time: number;
readonly actor: string;
readonly seq: number;
readonly ops: number;
} & Query.RecordResult>
history =
import Query
Query.
constselect: <Filter.Filter<{
readonly key: string;
readonly source: "document" | "feed";
readonly time: number;
readonly actor: string;
readonly seq: number;
readonly ops: number;
} & Query.RecordResult>>(filter: Filter.Filter<{
readonly key: string;
readonly source: "document" | "feed";
readonly time: number;
readonly actor: string;
readonly seq: number;
readonly ops: number;
} & Query.RecordResult>) =>Query.Query<{
readonly key: string;
readonly source: "document" | "feed";
readonly time: number;
readonly actor: string;
readonly seq: number;
readonly ops: number;
} & Query.RecordResult>
Select objects based on a filter.
@param ― filter - Filter to select the objects.
@returns ― Query for the selected objects.
@performance ― O(1); wraps the current AST in a new immutable node without executing anything.
per change to the documents
holding targets, or to every document in the space when called with no argument.
Changes belong to documents, not entities. Entities that share a document share its changes, and
content held by another entity (a document's Text) needs its own target. Only the host answers
these queries; a space-wide query must aggregate, and the index answers it only at hour
granularity (see Aggregate.time).