import { Hologram, hologramCtor, InternalHologram } from "./hologram"; import { Subject } from "rxjs"; import { Bitnode } from "./bitnode"; /** * A filter for a {@link Query}. * * Uses equality for comparison. */ export interface QueryFilter { /** * The name of the field to filter on. */ name: string; /** * The value to filter for. */ value: any; } /** * A sorting for a {@link Query}. * * Uses the field name and ascending flag to determine the sorting order. */ export interface QuerySorting { /** * The name of the field to sort on. */ name: string; /** * The sorting order. */ ascending: boolean; } /** * A query for holograms. */ export interface Query { /** * The model version to query for. */ model: string; /** * The [filters]{@link QueryFilter} to apply. */ filters?: QueryFilter[]; /** * The [sortings]{@link QuerySorting} to apply. */ sortings?: QuerySorting[]; /** * The maximum number of results to return. */ limit?: number; /** * The offset to start at. */ offset?: number; } /** * A result of a {@link Query}. */ export declare class QueryResult { protected bitnode: Bitnode; protected ctor: hologramCtor; protected _id: string; protected _set: Map; protected _added: Subject; protected _removed: Subject; protected _initialDone: Subject; protected _query: Query; /** * Creates a new query result. * * @param bitnode The bitnode to use for the query. * @param id The ID of the query. * @param ctor The constructor of the hologram type. * @param query The query to use. */ constructor(bitnode: Bitnode, id: string, ctor: hologramCtor, query: Query); /** * The {@link Query} used for this result. */ get query(): Query; /** * The set of holograms in the result. */ get set(): T[]; /** * Subject that emits when a hologram is added to the result. */ get added(): Subject; /** * Subject that emits when a hologram is removed from the result. */ get removed(): Subject; /** * Subject that emits when the initial result is done. */ get initialDone(): Subject; /** * Detaches the query from the bitnode, stopping the result from updating. */ detach(): Promise; } /** * @internal */ export declare class QueryResultInternal extends QueryResult { constructor(bitnode: Bitnode, id: string, ctor: hologramCtor, query: Query); emitAdd(hologram: InternalHologram): void; emitRemove(id: string): void; emitInitialDone(): void; }