我試圖在$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 }