Skip to content

Commit b03faf5

Browse files
committed
fix(query): allow findOne(objectid) and find(objectid)
Fix #8268
1 parent d7ceb89 commit b03faf5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/cast.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ module.exports = function cast(schema, obj, options, context) {
2828
}
2929

3030
// bson 1.x has the unfortunate tendency to remove filters that have a top-level
31-
// `_bsontype` property. Should remove this when we upgrade to bson 4.x. See gh-8222
32-
if (obj.hasOwnProperty('_bsontype')) {
31+
// `_bsontype` property. But we should still allow ObjectIds because
32+
// `Collection#find()` has a special case to support `find(objectid)`.
33+
// Should remove this when we upgrade to bson 4.x. See gh-8222, gh-8268
34+
if (obj.hasOwnProperty('_bsontype') && obj._bsontype !== 'ObjectID') {
3335
delete obj._bsontype;
3436
}
3537

0 commit comments

Comments
 (0)