【发布时间】:2013-04-21 13:24:29
【问题描述】:
我正在尝试在$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 }
【问题讨论】: