Skip to content

Commit

Permalink
Merge pull request #13651 from Automattic/IslandRhythms/deprecate-ove…
Browse files Browse the repository at this point in the history
…rwrite

Island rhythms/deprecate overwrite
  • Loading branch information
vkarpov15 committed Jul 25, 2023
2 parents 70fa116 + bd15a91 commit 370c32d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,15 @@ const printRawResultDeprecationWarning = util.deprecate(
'The `rawResult` option for Mongoose queries is deprecated. Use `includeResultMetadata: false` as a replacement for `rawResult: true`.'
);

/*!
* 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
Expand Down Expand Up @@ -3283,6 +3292,10 @@ 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();
Expand Down

0 comments on commit 370c32d

Please sign in to comment.