>我有一个架构如下
var S = new Schems({
f : Mixed
})
猫鼬模型('collection', S);
如何查询"集合",以便找到f
是任何 mongo ObjectId
的文档?
例如,如果"
collection' = [{ f: ObjectId('549138f19f52f268c717a8a2'), _id : 1 },
{ f : ObjectId('549139129f52f268c717a8a4'), _id : 2 }, { f : false, _id :3 } ]
结果应具有_id 1 和 2
您正在请求$type
运算符。对象 ID 类型为"7"类型:
Collection.find({ "f": { "$type": 7 } },function(err,docs) {
// results in here
});