@couchbase/lite-js
    Preparing search index...

    Class Query<Schema>

    A compiled N1QL query. Created by Database.createQuery.

    Type Parameters

    • Schema extends SchemaLike<Schema> = NoSchema

      The database schema type, inherited from its Database.

    Index

    Properties

    columnNames: readonly string[]

    The names of the result columns, i.e. the keys in a row object.

    database: Database<Schema>

    The Database being queried.

    Accessors

    • get explanation(): string

      A string that describes in human-readable form the steps the query will perform when it runs. (Format subject to change without notice.)

      Returns string

    • get parameterNames(): Set<string>

      The names of all query parameters.

      Returns Set<string>

    • get parameters(): Record<string, JSONValue>

      A map from query parameter names to their values.

      You must set the values of all parameters before running the query.

      Changing any parameter value will cause query change listeners to re-evaluate the query, triggering the callback if the results change.

      Note: Omit the "$" in the keys: if the N1QL query uses $date, the key is "date".

      Returns Record<string, JSONValue>

    • set parameters(p: Record<string, JSONValue>): void

      Parameters

      Returns void

    Methods

    • Runs the query, returning an array of rows.

      Type Parameters

      • T extends QueryAliases<T> = JSONObject

        The type of the returned rows; defaults to JSONObject. This is not type-checked, so it's up to you to make it accurate.

      Returns Promise<T[]>

      InterruptedQueryError if interrupt was called during execution.

    • Runs the query, calling the callback for each row.

      Type Parameters

      • T extends QueryAliases<T> = JSONObject

        The type of the returned rows; defaults to JSONObject. This is not type-checked, so it's up to you to make it accurate.

      Parameters

      • callback: (doc: T) => void

      Returns Promise<boolean>

      True if the query completed, false if it was interrupted.

    • Stops an active execute call ASAP. Does nothing if the query is not running.

      Returns void

    • Registers a custom N1QL function.

      Registration is global: it will be available in all queries on all Databases.

      Parameters

      Returns void