Interface QueryContract<DocumentType>

interface QueryContract<DocumentType> {
    "[asyncIterator]"(): AsyncIterableIterator<DocumentType, any, any>;
    all(): Promise<DocumentType[]>;
    count(): Promise<number>;
    distinct<T = unknown>(key: string): Promise<T[]>;
    explain(verbosity?: ExplainVerbosityLike): Promise<Document>;
    first(): Promise<null | DocumentType>;
    firstOrFail(): Promise<DocumentType>;
    limit(number: number): this;
    skip(number: number): this;
    sort(sort: QuerySortObject): this;
    sortBy(field: string, direction?: SortDirection): this;
}

Type Parameters

  • DocumentType

Methods

  • Counts all matching documents. Calling this method after skip or limit might not count everything.

    Returns Promise<number>

  • Performs a distinct query.

    Type Parameters

    • T = unknown

    Parameters

    • key: string

    Returns Promise<T[]>

  • Performs an explain query.

    Parameters

    • Optionalverbosity: ExplainVerbosityLike

    Returns Promise<Document>

  • Limit the result to number entries. Cancels any previous limit call.

    Parameters

    • number: number

    Returns this

  • Skip number entries. Cancels any previous skip call.

    Parameters

    • number: number

    Returns this

  • Add a new criterion to the sort.

    Parameters

    • field: string
    • Optionaldirection: SortDirection

    Returns this