0
我需要计数主文档的子文档。方案只是一个例子:猫鼬 - 计数子文档
型号:
{
title: {type: String, required: true},
content: {type: String, required: true},
comments: [{
comment: {type: String, required: true},
author: {type: String, required: true}
}]
}
该查询不起作用:
Model.findById(ObjectId).count('comments', function(err, res) {
if (err) { throw err; }
else { console.log(res); }
});
我怎么能算一些文档中的注释?