Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface PickRandomPluginStatics<TDocData, TDoc>

Type parameters

  • TDocData: BasicObject

  • TDoc: Document

Hierarchy

Index

Methods

tryPickRandomDocuments

  • tryPickRandomDocuments<ProjectedData>(this: Model<TDoc>, docsAmount: number, projection?: Maybe<ProjectionOperand<TDocData>>): Promise<ProjectedData[]>
  • Tries to pick random docsAmount of unique documents from the database collection.

    throws

    NotEnoughDocumentsError if docsAmount is greater than the total amount of documents stored in the database collection.

    Type parameters

    • ProjectedData

    Parameters

    • this: Model<TDoc>
    • docsAmount: number

      Exact amount of documents to pick randomly.

    • Optional projection: Maybe<ProjectionOperand<TDocData>>

      Projection stage operator to apply to retrieved documents.

    Returns Promise<ProjectedData[]>

Generated using TypeDoc