我试图在$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);
}
});
任何人都可以告诉我它在哪里出错或正确的语法?
我即使更换
'Field2': { $regex: /Value_2/g }