Interface QueryOptions<DocType>

interface QueryOptions<DocType> {
    arrayFilters?: {
        [key: string]: any;
    }[];
    batchSize?: number;
    collation?: CollationOptions;
    comment?: any;
    context?: string;
    explain?: ExplainVerbosityLike;
    fields?: any;
    hint?: Hint;
    includeResultMetadata?: boolean;
    lean?: boolean | Record<string, any>;
    limit?: number;
    maxTimeMS?: number;
    multi?: boolean;
    multipleCastError?: boolean;
    new?: boolean;
    overwriteDiscriminatorKey?: boolean;
    populate?: string | string[] | PopulateOptions | PopulateOptions[];
    projection?: ProjectionType<DocType>;
    rawResult?: boolean;
    readPreference?: string;
    returnDocument?: "before" | "after";
    returnOriginal?: boolean;
    runValidators?: boolean;
    sanitizeFilter?: boolean;
    sanitizeProjection?: boolean;
    session?: mongoose.mongo.ClientSession;
    setDefaultsOnInsert?: boolean;
    skip?: number;
    sort?: any;
    strict?: string | boolean;
    strictQuery?: boolean | "throw";
    tailable?: number;
    timestamps?: boolean | QueryTimestampsConfig;
    translateAliases?: boolean;
    upsert?: boolean;
    useBigInt64?: boolean;
    writeConcern?: mongoose.mongo.WriteConcern;
    [other: string]: any;
}

Type Parameters

  • DocType = unknown

Hierarchy (view full)

Indexable

[other: string]: any

Properties

arrayFilters?: {
    [key: string]: any;
}[]

Type declaration

  • [key: string]: any
batchSize?: number
collation?: CollationOptions
comment?: any
context?: string
fields?: any
hint?: Hint
includeResultMetadata?: boolean

if ture, includes meta data for the result from the MongoDB driver

lean?: boolean | Record<string, any>

If truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document.

limit?: number
maxTimeMS?: number
multi?: boolean
multipleCastError?: boolean
new?: boolean

By default, findOneAndUpdate() returns the document as it was before update was applied. If you set new: true, findOneAndUpdate() will instead give you the object after update was applied.

overwriteDiscriminatorKey?: boolean
populate?: string | string[] | PopulateOptions | PopulateOptions[]
projection?: ProjectionType<DocType>
rawResult?: boolean

Deprecated

use includeResultMetadata instead. if true, returns the raw result from the MongoDB driver

readPreference?: string
returnDocument?: "before" | "after"

Another alias for the new option. returnOriginal is deprecated so this should be used.

returnOriginal?: boolean

An alias for the new option. returnOriginal: false is equivalent to new: true.

runValidators?: boolean

Set to true to enable update validators (https://mongoosejs.com/docs/validation.html#update-validators). Defaults to false.

sanitizeFilter?: boolean

Set to true to automatically sanitize potentially unsafe query filters by stripping out query selectors that aren't explicitly allowed using mongoose.trusted().

sanitizeProjection?: boolean
setDefaultsOnInsert?: boolean
skip?: number
sort?: any
strict?: string | boolean

overwrites the schema's strict mode option

strictQuery?: boolean | "throw"

equal to strict by default, may be false, true, or 'throw'. Sets the default strictQuery mode for schemas.

tailable?: number
timestamps?: boolean | QueryTimestampsConfig

If set to false and schema-level timestamps are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.

translateAliases?: boolean

If true, convert any aliases in filter, projection, update, and distinct to their database property names. Defaults to false.

upsert?: boolean
useBigInt64?: boolean
writeConcern?: mongoose.mongo.WriteConcern