diff --git a/test/types/queries.test.ts b/test/types/queries.test.ts index efdce8ff9f3..6f384c00209 100644 --- a/test/types/queries.test.ts +++ b/test/types/queries.test.ts @@ -544,3 +544,29 @@ function gh14190() { ModifyResult> >(res2); } + +function mongooseQueryOptions() { + const userSchema = new Schema({ name: String, age: Number }); + const UserModel = model('User', userSchema); + + UserModel.updateOne( + { name: 'bar' }, + { name: 'baz' }, + { + multipleCastError: true, + overwriteDiscriminatorKey: true, + runValidators: true, + sanitizeProjection: true, + sanitizeFilter: true, + strict: true, + strictQuery: 'throw', + timestamps: false, + translateAliases: false + } + ); + + UserModel.findOne({}, null, { + lean: true, + populate: 'test' + }); +} diff --git a/types/query.d.ts b/types/query.d.ts index 9e3d445d26c..906bad50425 100644 --- a/types/query.d.ts +++ b/types/query.d.ts @@ -17,13 +17,19 @@ declare module 'mongoose' { */ type FilterQuery = _FilterQuery; - type MongooseQueryOptions = Pick, 'populate' | - 'lean' | - 'strict' | - 'sanitizeProjection' | - 'sanitizeFilter' | - 'timestamps' | - 'translateAliases' + type MongooseQueryOptions = Pick< + QueryOptions, + 'lean' | + 'multipleCastError' | + 'overwriteDiscriminatorKey' | + 'populate' | + 'runValidators' | + 'sanitizeProjection' | + 'sanitizeFilter' | + 'strict' | + 'strictQuery' | + 'timestamps' | + 'translateAliases' >; type ProjectionFields = { [Key in keyof DocType]?: any } & Record;