Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Query<ResultType, DocType, THelpers, RawDocType>

Type Parameters

  • ResultType

  • DocType

  • THelpers = {}

  • RawDocType = DocType

Hierarchy

  • Query

Implements

Index

Constructors

  • new Query<ResultType, DocType, THelpers, RawDocType>(): Query<ResultType, DocType, THelpers, RawDocType>
  • Type Parameters

    • ResultType

    • DocType

    • THelpers = {}

    • RawDocType = DocType

    Returns Query<ResultType, DocType, THelpers, RawDocType>

Properties

_mongooseOptions: MongooseQueryOptions<DocType>
catch: (<TResult>(onrejected?: ((reason: any) => TResult | <internal>.PromiseLike<TResult>)) => Promise<ResultType | TResult>)

Type declaration

    • <TResult>(onrejected?: ((reason: any) => TResult | <internal>.PromiseLike<TResult>)): Promise<ResultType | TResult>
    • Attaches a callback for only the rejection of the Promise.

      Type Parameters

      • TResult = never

      Parameters

      Returns Promise<ResultType | TResult>

      A Promise for the completion of the callback.

model: <internal>.Model<any, {}, {}, {}, any>

The model this query was created from

then: (<TResult1, TResult2>(onfulfilled?: ((value: ResultType) => TResult1 | <internal>.PromiseLike<TResult1>), onrejected?: ((reason: any) => TResult2 | <internal>.PromiseLike<TResult2>)) => Promise<TResult1 | TResult2>)

Type declaration

    • <TResult1, TResult2>(onfulfilled?: ((value: ResultType) => TResult1 | <internal>.PromiseLike<TResult1>), onrejected?: ((reason: any) => TResult2 | <internal>.PromiseLike<TResult2>)): Promise<TResult1 | TResult2>
    • Attaches callbacks for the resolution and/or rejection of the Promise.

      Type Parameters

      • TResult1 = ResultType

      • TResult2 = never

      Parameters

      Returns Promise<TResult1 | TResult2>

      A Promise for the completion of which ever callback is executed.

Methods

  • Returns a wrapper around a mongodb driver cursor. A QueryCursor exposes a Streams3 interface, as well as a .next() function. This is equivalent to calling .cursor() with no arguments.

    Returns <internal>.AsyncIterableIterator<DocType>

  • Executes the query

    Parameters

    Returns void

  • Returns Promise<ResultType>

  • $where(argument: string | Function): QueryWithHelpers<DocType[], DocType, THelpers, RawDocType>
  • Parameters

    • argument: string | Function

    Returns QueryWithHelpers<DocType[], DocType, THelpers, RawDocType>

  • all(path: string, val: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • all(val: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies an $all query condition. When called with one argument, the most recent path passed to where() is used.

    Parameters

    • path: string
    • val: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • allowDiskUse(value: boolean): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets the allowDiskUse option for the query (ignored for < 4.4.0)

    Parameters

    • value: boolean

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • and(array: FilterQuery<DocType>[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies arguments for an $and condition.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • batchSize(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies the batchSize option.

    Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • box(lower: number[], upper: number[]): Query<ResultType, DocType, THelpers, RawDocType>
  • box(val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $box condition

    Parameters

    • lower: number[]
    • upper: number[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Casts this query to the schema of model.

    Parameters

    • Optional model: <internal>.Model<any, THelpers, {}, {}, any>
    • Optional obj: any

    Returns any

    the casted obj

  • circle(path: string, area: any): Query<ResultType, DocType, THelpers, RawDocType>
  • circle(area: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $center or $centerSphere condition.

    Parameters

    • path: string
    • area: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • area: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • clone(): Query<ResultType, DocType, THelpers, RawDocType>
  • Make a copy of this query so you can re-execute it.

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Adds a collation to this op (MongoDB 3.4 and up)

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • comment(val: string): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies the comment option.

    Parameters

    • val: string

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Specifies this query as a count query.

    Parameters

    Returns QueryWithHelpers<number, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<number, DocType, THelpers, RawDocType>

  • Specifies this query as a countDocuments query.

    Parameters

    Returns QueryWithHelpers<number, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<number, DocType, THelpers, RawDocType>

  • Returns a wrapper around a mongodb driver cursor. A QueryCursor exposes a Streams3 interface, as well as a .next() function.

    Parameters

    Returns Cursor<DocType, QueryOptions<DocType>>

  • Declare and/or execute this query as a deleteMany() operation. Works like remove, except it deletes every document that matches filter in the collection, regardless of the value of single.

    Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Declare and/or execute this query as a deleteOne() operation. Works like remove, except it deletes at most one document regardless of the single option.

    Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Creates a distinct query: returns the distinct values of the given field that match filter.

    Type Parameters

    • ReturnType = any

    Parameters

    Returns QueryWithHelpers<ReturnType[], DocType, THelpers, RawDocType>

  • elemMatch<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • elemMatch(val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $elemMatch query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Gets/sets the error flag on this query. If this flag is not null or undefined, the exec() promise will reject without executing.

    Returns NativeError

  • Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • equals(val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies the complementary comparison value for paths specified with where()

    Parameters

    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Creates a estimatedDocumentCount query: counts the number of documents in the collection.

    Parameters

    Returns QueryWithHelpers<number, DocType, THelpers, RawDocType>

  • exists<K>(path: K, val: boolean): Query<ResultType, DocType, THelpers, RawDocType>
  • exists(val: boolean): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $exists query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: boolean

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: boolean

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Sets the explain option, which makes this query return detailed execution stats instead of the actual query result. This method is useful for determining what index your queries use.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Creates a findOneAndDelete query: atomically finds the given document, deletes it, and returns the document as it was before deletion.

    Parameters

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Creates a findOneAndRemove query: atomically finds the given document and deletes it.

    Parameters

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Declares the query a findById operation. When executed, the document with the given _id is passed to the callback.

    Parameters

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Parameters

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Creates a findByIdAndDelete query, filtering by the given _id.

    Parameters

    • Optional id: any
    • Optional options: QueryOptions<DocType>
    • Optional callback: ((err: NativeError, doc: DocType, res: any) => void)

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • findByIdAndUpdate(id: any, update: UpdateQuery<DocType>, options: QueryOptions<DocType> & { rawResult: true }, callback?: ((err: NativeError, doc: any, res?: any) => void)): QueryWithHelpers<any, DocType, THelpers, RawDocType>
  • findByIdAndUpdate(id: any, update: UpdateQuery<DocType>, options: QueryOptions<DocType> & { upsert: true } & { new: true } & QueryOptions<DocType> & { upsert: true } & { returnOriginal: false } & QueryOptions<DocType> & { upsert: true } & { returnDocument: "after" }, callback?: ((err: NativeError, doc: DocType, res?: any) => void)): QueryWithHelpers<DocType, DocType, THelpers, RawDocType>
  • findByIdAndUpdate(id?: any, update?: UpdateQuery<DocType>, options?: QueryOptions<DocType>, callback?: ((CallbackError: any, doc: DocType, res?: any) => void)): QueryWithHelpers<DocType, DocType, THelpers, RawDocType>
  • findByIdAndUpdate(id: any, update: UpdateQuery<DocType>, callback: ((CallbackError: any, doc: DocType, res?: any) => void)): QueryWithHelpers<DocType, DocType, THelpers, RawDocType>
  • Creates a findOneAndUpdate query, filtering by the given _id.

    Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • Parameters

    • id: any
    • update: UpdateQuery<DocType>
    • options: QueryOptions<DocType> & { upsert: true } & { new: true } & QueryOptions<DocType> & { upsert: true } & { returnOriginal: false } & QueryOptions<DocType> & { upsert: true } & { returnDocument: "after" }
    • Optional callback: ((err: NativeError, doc: DocType, res?: any) => void)
        • Parameters

          Returns void

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Parameters

    • Optional id: any
    • Optional update: UpdateQuery<DocType>
    • Optional options: QueryOptions<DocType>
    • Optional callback: ((CallbackError: any, doc: DocType, res?: any) => void)
        • (CallbackError: any, doc: DocType, res?: any): void
        • Parameters

          • CallbackError: any
          • doc: DocType
          • Optional res: any

          Returns void

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • Parameters

    • id: any
    • update: UpdateQuery<DocType>
    • callback: ((CallbackError: any, doc: DocType, res?: any) => void)
        • (CallbackError: any, doc: DocType, res?: any): void
        • Parameters

          • CallbackError: any
          • doc: DocType
          • Optional res: any

          Returns void

    Returns QueryWithHelpers<DocType, DocType, THelpers, RawDocType>

  • geometry(object: { type: string; coordinates: any[] }): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $geometry condition

    Parameters

    • object: { type: string; coordinates: any[] }
      • type: string
      • coordinates: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • get(path: string): any
  • For update operations, returns the value of a path in the update's $set. Useful for writing getters/setters that can work with both update operations and save().

    Parameters

    • path: string

    Returns any

  • Returns the current query filter (also known as conditions) as a POJO.

    Returns FilterQuery<DocType>

  • Gets query options.

    Returns QueryOptions<DocType>

  • getPopulatedPaths(): string[]
  • Gets a list of paths to be populated by this query

    Returns string[]

  • Returns the current query filter. Equivalent to getFilter().

    Returns FilterQuery<DocType>

  • gt<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • gt(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $gt query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • gte<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • gte(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $gte query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • hint(val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets query hints.

    Parameters

    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • in<K>(path: K, val: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • in(val: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies an $in query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • intersects(arg?: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Declares an intersects query for geometry().

    Parameters

    • Optional arg: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • j(val: boolean): Query<ResultType, DocType, THelpers, RawDocType>
  • Requests acknowledgement that this operation has been persisted to MongoDB's on-disk journal.

    Parameters

    • val: boolean

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • lean<LeanResultType>(val?: any): QueryWithHelpers<LeanResultType, DocType, THelpers, RawDocType>
  • limit(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies the maximum number of documents the query will return.

    Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • lt<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • lt(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $lt query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • lte<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • lte(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $lte query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • transform<MappedType>(fn: ((doc: ResultType) => MappedType)): QueryWithHelpers<MappedType, DocType, THelpers, RawDocType>
  • Runs a function fn and treats the return value of fn as the new value for the query to resolve to.

    Type Parameters

    • MappedType

    Parameters

    • fn: ((doc: ResultType) => MappedType)
        • (doc: ResultType): MappedType
        • Parameters

          • doc: ResultType

          Returns MappedType

    Returns QueryWithHelpers<MappedType, DocType, THelpers, RawDocType>

  • maxDistance(path: string, val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • maxDistance(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies an $maxDistance query condition. When called with one argument, the most recent path passed to where() is used.

    Parameters

    • path: string
    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • maxScan(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies the maxScan option.

    Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • maxTimeMS(ms: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets the maxTimeMS option. This will tell the MongoDB server to abort if the query or write op has been running for more than ms milliseconds.

    Parameters

    • ms: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • merge(source: FilterQuery<DocType> | Query<any, any, {}, any>): Query<ResultType, DocType, THelpers, RawDocType>
  • Merges another Query or conditions object into this one.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • mod<K>(path: K, val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • mod(val: number[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $mod condition, filters documents for documents whose path property is a number that is equal to remainder modulo divisor.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Getter/setter around the current mongoose-specific options for this query Below are the current Mongoose-specific options.

    Parameters

    Returns MongooseQueryOptions<unknown>

  • ne<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • ne(val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $ne query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • near<K>(path: K, val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • near(val: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $near or $nearSphere condition

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • nin<K>(path: K, val: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • nin(val: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies an $nin query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • nor(array: FilterQuery<DocType>[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies arguments for an $nor condition.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • or(array: FilterQuery<DocType>[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies arguments for an $or condition.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Make this query throw an error if no documents match the given filter. This is handy for integrating with async/await, because orFail() saves you an extra if statement to check if no document was found.

    Parameters

    Returns QueryWithHelpers<NonNullable<ResultType>, DocType, THelpers, RawDocType>

  • polygon(path: string, ...coordinatePairs: number[][]): Query<ResultType, DocType, THelpers, RawDocType>
  • polygon(...coordinatePairs: number[][]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $polygon condition

    Parameters

    • path: string
    • Rest ...coordinatePairs: number[][]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • Rest ...coordinatePairs: number[][]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Get/set the current projection (AKA fields). Pass null to remove the current projection.

    Parameters

    Returns ProjectionFields<DocType>

  • Parameters

    • fields: null

    Returns null

  • Returns ProjectionFields<DocType>

  • read(pref: string, tags?: any[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Determines the MongoDB nodes from which to read.

    Parameters

    • pref: string
    • Optional tags: any[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • readConcern(level: string): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets the readConcern option for the query.

    Parameters

    • level: string

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • regex<K>(path: K, val: RegExp): Query<ResultType, DocType, THelpers, RawDocType>
  • regex(val: string | RegExp): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $regex query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: RegExp

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: string | RegExp

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Declare and/or execute this query as a replaceOne() operation. Same as update(), except MongoDB will replace the existing document and will not accept any atomic operators ($set, etc.)

    Parameters

    Returns QueryWithHelpers<any, DocType, THelpers, RawDocType>

  • select(arg: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies which document fields to include or exclude (also known as the query "projection")

    Parameters

    • arg: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • selected(): boolean
  • Determines if field selection has been made.

    Returns boolean

  • selectedExclusively(): boolean
  • Determines if exclusive field selection has been made.

    Returns boolean

  • selectedInclusively(): boolean
  • Determines if inclusive field selection has been made.

    Returns boolean

  • set(path: string | <internal>.Record<string, unknown>, value?: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Adds a $set to this query's update without changing the operation. This is useful for query middleware so you can add an update regardless of whether you use updateOne(), updateMany(), findOneAndUpdate(), etc.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • setOptions(options: QueryOptions<DocType>, overwrite?: boolean): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets query options. Some options only make sense for certain operations.

    Parameters

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Sets the query conditions to the provided JSON object.

    Parameters

    Returns void

  • size<K>(path: K, val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • size(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies an $size query condition. When called with one argument, the most recent path passed to where() is used.

    Type Parameters

    • K = string

    Parameters

    • path: K
    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • skip(val: number): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies the number of documents to skip.

    Parameters

    • val: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • slice(path: string, val: number | number[]): Query<ResultType, DocType, THelpers, RawDocType>
  • slice(val: number | number[]): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a $slice projection for an array.

    Parameters

    • path: string
    • val: number | number[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • val: number | number[]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • snapshot(val?: boolean): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies this query as a snapshot query.

    Parameters

    • Optional val: boolean

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • sort(arg?: string | {} | [string, SortOrder][]): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets the sort order. If an object is passed, values allowed are asc, desc, ascending, descending, 1, and -1.

    Parameters

    • Optional arg: string | {} | [string, SortOrder][]

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • tailable(bool?: boolean, opts?: { numberOfRetries?: number; tailableRetryInterval?: number }): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets the tailable option (for use with capped collections).

    Parameters

    • Optional bool: boolean
    • Optional opts: { numberOfRetries?: number; tailableRetryInterval?: number }
      • Optional numberOfRetries?: number
      • Optional tailableRetryInterval?: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • toConstructor<RetType>(): RetType
  • Converts this query to a customized, reusable query constructor with all arguments and options retained.

    Type Parameters

    Returns RetType

  • w(val: string | number): Query<ResultType, DocType, THelpers, RawDocType>
  • Sets the specified number of mongod servers, or tag set of mongod servers, that must acknowledge this write before this write is considered successful.

    Parameters

    • val: string | number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • where(path: string, val?: any): Query<ResultType, DocType, THelpers, RawDocType>
  • where(obj: object): Query<ResultType, DocType, THelpers, RawDocType>
  • where(): Query<ResultType, DocType, THelpers, RawDocType>
  • Specifies a path for use with chaining.

    Parameters

    • path: string
    • Optional val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Parameters

    • obj: object

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • Returns Query<ResultType, DocType, THelpers, RawDocType>

  • within(val?: any): Query<ResultType, DocType, THelpers, RawDocType>
  • Defines a $within or $geoWithin argument for geo-spatial queries.

    Parameters

    • Optional val: any

    Returns Query<ResultType, DocType, THelpers, RawDocType>

  • wtimeout(ms: number): Query<ResultType, DocType, THelpers, RawDocType>
  • If w > 1, the maximum amount of time to wait for this write to propagate through the replica set before this operation fails. The default is 0, which means no timeout.

    Parameters

    • ms: number

    Returns Query<ResultType, DocType, THelpers, RawDocType>

Generated using TypeDoc