aggregate match时使用操作符是无效的
文档最后那行实际输出的结果是7,而不是3,说明aggregate match时使用操作符_.gt是无效的,等同没有此条件,实际返回所有数据。
{ "_id" : "1", "author" : "stark", "score" : 80 }{ "_id" : "2", "author" : "stark", "score" : 85 }{ "_id" : "3", "author" : "bob", "score" : 60 }{ "_id" : "4", "author" : "li", "score" : 55 }{ "_id" : "5", "author" : "jimmy", "score" : 60 }{ "_id" : "6", "author" : "li", "score" : 94 }{ "_id" : "7", "author" : "justan", "score" : 95 } |
const db = wx.cloud.database()const _ = db.commandconst $ = _.aggregatedb.collection('article') .aggregate() .match({ score: _.gt(80) }) .group({ _id: null, count: $.sum(1) }) .end() |
预期结果:
{ "_id" : null, "count" : 3 } |
实际结果:
{ "_id" : null, "count" : 7 } |
