@squidcloud/client
    Preparing search index...

    Class QueryBuilder<DocumentType>

    A query builder that can be used to build a query that returns a list of documents.

    Type Parameters

    Hierarchy (View Summary)

    Implements

    Index

    Accessors

    • get hash(): string

      A unique hash for the query. Identical queries should return the same hash value.

      Returns string

      The query's hash string.

    Methods

    • Adds a condition to the query to check if the specified field includes all the given values.

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to query.

      • values: PrimitiveFieldType[]

        The values to check for inclusion in the field array.

      Returns this

      The query builder.

    • Adds a condition to the query to check if the specified field includes any of the given values.

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to query.

      • values: PrimitiveFieldType[]

        The values to check for inclusion in the field array.

      Returns this

      The query builder.

    • Adds a condition to the query to check if the specified field does not include any of the given values.

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to query.

      • values: PrimitiveFieldType[]

        The values to check for non-inclusion in the field array.

      Returns this

      The query builder.

    • A shortcut for where(fieldName, 'like', pattern).

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to query.

      • pattern: string

        The pattern to compare against. '%' matches 0 or more characters. '' matches exactly one character. '' can be used to escape '%', ''. or another ''. Note that any '' that is not followed by '%', '_', or '' is invalid.

      • OptionalcaseSensitive: boolean

        Whether to use case-sensitive comparison. Defaults to true.

      Returns this

      The query builder.

    • Sets a limit to the number of results returned by the query. The maximum limit is 20,000 and the default is 1,000 if none is provided.

      Parameters

      • limit: number

        The limit to set.

      Returns this

      The query builder.

    • Parameters

      • limit: number
      • ...fields: string[]

      Returns this

    • A shortcut for where(fieldName, 'not like', pattern).

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to query.

      • pattern: string

        The pattern to compare against. '%' matches 0 or more characters. '' matches exactly one character. '' can be used to escape '%', ''. or another ''. Note that any '' that is not followed by '%', '_', or '' is invalid.

      • OptionalcaseSensitive: boolean

        Whether to use case-sensitive comparison. Defaults to true.

      Returns this

      The query builder.

    • Returns the results of the query based on the data that is currently available on the client. This method is useful for synchronously accessing data that has already been fetched by another query. The method will return an empty array if data has not yet been populated.

      Returns DocumentReference<DocumentType>[]

      An array of query results.

    • Forces the query to return data from the server even if there is a query that already returned the requested result.

      Returns this

    • Returns an observable that emits the query results and updates whenever the query results change unless subscribe=false is provided.

      Important: Make sure to unsubscribe from the observable when you are done with it.

      Parameters

      • subscribe: boolean = true

        Whether to subscribe to changes to the query results. Defaults to true.

      Returns Observable<DocumentReference<DocumentType>[]>

      An observable for the query results.

    • Adds a sort order to the query. You can add multiple sort orders to the query. The order in which you add them determines the order in which they are applied.

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to sort by.

      • asc: boolean = true

        Whether to sort in ascending order. Defaults to true.

      Returns this

      The query builder.

    • Adds a condition to the query.

      Parameters

      • fieldName: string | keyof DocumentType & string

        The name of the field to query.

      • operator:
            | "in"
            | "not in"
            | "array_includes_some"
            | "array_includes_all"
            | "array_not_includes"
            | "=="
            | "!="
            | ">="
            | "<="
            | ">"
            | "<"
            | "like"
            | "not like"
            | "like_cs"
            | "not like_cs"

        The operator to use.

      • value: PrimitiveFieldType | PrimitiveFieldType[]

        The value to compare against.

      Returns this

      The query builder.