diff --git a/lib/cast.js b/lib/cast.js index 928fe9d1ba4..3dfd651acd2 100644 --- a/lib/cast.js +++ b/lib/cast.js @@ -27,6 +27,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; + } + const paths = Object.keys(obj); let i = paths.length; let _keys;