Skip to content

Commit 370381a

Browse files
committed
fix(mongoose): correctly handle destructured isValidObjectId
Fix #11304 Re: #11305
1 parent 9f897ea commit 370381a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,9 @@ Mongoose.prototype.ObjectId = SchemaTypes.ObjectId;
955955
*/
956956

957957
Mongoose.prototype.isValidObjectId = function(v) {
958+
const _mongoose = this instanceof Mongoose ? this : mongoose;
958959
try {
959-
new this.Types.ObjectId(v);
960+
new _mongoose.Types.ObjectId(v);
960961
} catch (err) {
961962
return false;
962963
}

0 commit comments

Comments
 (0)