diff --git a/lib/cast.js b/lib/cast.js index 7f475edfeb4..339c031f14d 100644 --- a/lib/cast.js +++ b/lib/cast.js @@ -23,6 +23,12 @@ module.exports = function cast(schema, obj, options, context) { throw new Error('Query filter must be an object, got an array ', util.inspect(obj)); } + // 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')) { + delete obj._bsontype; + } + var paths = Object.keys(obj); var i = paths.length; var _keys;