Interface QueryContract<DocumentType>

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

Type Parameters

  • DocumentType

Methods

  • Returns an iterator on all matching documents.

    Returns AsyncIterableIterator<DocumentType>

  • Returns all matching documents.

    Returns Promise<DocumentType[]>

  • 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

    • Optional verbosity: ExplainVerbosityLike

    Returns Promise<Document>

  • Returns the first matching document or null.

    Returns Promise<null | DocumentType>

  • Returns the first matching document or throws.

    Returns Promise<DocumentType>