Skip to content

Commit

Permalink
Merge pull request #11524 from anatolykopyl/docs-findOneAndReplace-fix
Browse files Browse the repository at this point in the history
fix: Model.findOneAndReplace docs
  • Loading branch information
AbdelrahmanHafez authored Mar 14, 2022
2 parents ab97a17 + 7ba11d6 commit 305630d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -2836,11 +2836,11 @@ Model.findByIdAndDelete = function(id, options, callback) {
*
* ####Examples:
*
* A.findOneAndReplace(conditions, options, callback) // executes
* A.findOneAndReplace(conditions, options) // return Query
* A.findOneAndReplace(conditions, callback) // executes
* A.findOneAndReplace(conditions) // returns Query
* A.findOneAndReplace() // returns Query
* A.findOneAndReplace(filter, replacement, options, callback) // executes
* A.findOneAndReplace(filter, replacement, options) // return Query
* A.findOneAndReplace(filter, replacement, callback) // executes
* A.findOneAndReplace(filter, replacement) // returns Query
* A.findOneAndReplace() // returns Query
*
* @param {Object} filter Replace the first document that matches this filter
* @param {Object} [replacement] Replace with this document
Expand All @@ -2861,8 +2861,10 @@ Model.findOneAndReplace = function(filter, replacement, options, callback) {

if (arguments.length === 1 && typeof filter === 'function') {
const msg = 'Model.findOneAndReplace(): First argument must not be a function.\n\n'
+ ' ' + this.modelName + '.findOneAndReplace(conditions, callback)\n'
+ ' ' + this.modelName + '.findOneAndReplace(conditions)\n'
+ ' ' + this.modelName + '.findOneAndReplace(filter, replacement, options, callback)\n'
+ ' ' + this.modelName + '.findOneAndReplace(filter, replacement, callback)\n'
+ ' ' + this.modelName + '.findOneAndReplace(filter, replacement)\n'
+ ' ' + this.modelName + '.findOneAndReplace(filter, callback)\n'
+ ' ' + this.modelName + '.findOneAndReplace()\n';
throw new TypeError(msg);
}
Expand Down

0 comments on commit 305630d

Please sign in to comment.