Skip to content

Commit

Permalink
fix(query): allow findOne(objectid) and find(objectid)
Browse files Browse the repository at this point in the history
Fix #8268
  • Loading branch information
vkarpov15 committed Oct 23, 2019
1 parent d7ceb89 commit b03faf5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/cast.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ module.exports = function cast(schema, obj, options, context) {
}

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

Expand Down

0 comments on commit b03faf5

Please sign in to comment.