我试图使用$match
中的$regex
,但它不返回匹配的文档.
db.collection('MyCollection', function (err, collection) {
collection.aggregate([
{ $match: { 'Code': 'Value_01', 'Field2': { $regex: '/Value_2/g' } } },
{ $project: {
_id: 1,
CodeNumber: '$Code',
FieldName2: '$Field2'
}
}
], function (err, Result_doc) {
console.log(Result_doc);
}
});
谁能告诉我哪里出了问题或者语法正确吗?
I even tried with replacing the
'Field2': { $regex: /Value_2/g }