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); }
});
我怎麼能算一些文檔中的註釋?