我在shell中构造了我想要的查询但是在Mongoose中编写它时遇到了麻烦.
db.commentstreams.group({ key: { page_id: true }, reduce: function(obj,prev) { prev.num_comments += obj.num_comments }, initial: { num_comments: 0 } })
Run Code Online (Sandbox Code Playgroud)
我对Mongoose语法感到有点困惑; 也许有人可以对这一点有所了解.非常感谢.