diff --git a/lib/query.js b/lib/query.js index 6b410d61c77..f048b3c5660 100644 --- a/lib/query.js +++ b/lib/query.js @@ -1670,15 +1670,6 @@ Query.prototype.setOptions = function(options, overwrite) { return this; }; -/*! - * ignore - */ - -const printOverwriteDeprecationWarning = util.deprecate( - function printOverwriteDeprecationWarning() {}, - 'The `overwrite` option for `findOneAndUpdate()` is deprecated. use `findOneAndReplace()` instead.' -); - /** * Sets the [`explain` option](https://www.mongodb.com/docs/manual/reference/method/cursor.explain/), * which makes this query return detailed execution stats instead of the actual @@ -3259,16 +3250,6 @@ Query.prototype.findOneAndUpdate = function(filter, doc, options) { */ Query.prototype._findOneAndUpdate = async function _findOneAndUpdate() { - // For backwards compability with Mongoose 6 re: #13550 - - if (this._mongooseOptions.overwrite != null) { - printOverwriteDeprecationWarning(); - } - if (this._mongooseOptions.overwrite) { - this.op = 'findOneAndReplace'; - return this._findOneAndReplace(); - } - this._castConditions(); _castArrayFilters(this); diff --git a/test/query.test.js b/test/query.test.js index 2c357b82fa1..1c4c86440b2 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -4156,16 +4156,6 @@ describe('Query', function() { /Query must have `op` before executing/ ); }); - it('converts findOneAndUpdate to findOneAndReplace if overwrite set (gh-13550)', async function() { - const testSchema = new Schema({ - name: { type: String } - }); - - const Test = db.model('Test', testSchema); - const q = Test.findOneAndUpdate({}, { name: 'bar' }, { overwrite: true }); - await q.exec(); - assert.equal(q.op, 'findOneAndReplace'); - }); it('allows deselecting discriminator key (gh-13760) (gh-13679)', async function() { const testSchema = new Schema({ name: String, age: Number }); diff --git a/types/inferschematype.d.ts b/types/inferschematype.d.ts index 98e5fd2ff7a..e4ea5ebe327 100644 --- a/types/inferschematype.d.ts +++ b/types/inferschematype.d.ts @@ -32,14 +32,14 @@ declare module 'mongoose' { EnforcedDocType : { [ - K in keyof (RequiredPaths & - OptionalPaths) + K in keyof (RequiredPaths & + OptionalPaths) ]: IsPathRequired extends true ? ObtainDocumentPathType : ObtainDocumentPathType | null; - }; + }; - /** + /** * @summary Obtains document schema type from Schema instance. * @param {Schema} TSchema `typeof` a schema instance. * @example @@ -48,7 +48,7 @@ declare module 'mongoose' { * // result * type UserType = {userName?: string} */ - export type InferSchemaType = IfAny>; + export type InferSchemaType = IfAny>; /** * @summary Obtains schema Generic type by using generic alias.