var commentSchema = new Schema({
text: String,
actions:[{actionid:String, actiondata:String}],
author: String
})
在获取记录时,我需要计算action = 1
。我想在每个评论中添加计数作为额外的键,如下所示:
{
"comments":[
{"commentData":{
"text":"temp1",
"author":"tempauthor1",
"actioncount":"2"
}},
{"commentData":{
"text":"temp1",
"author":"tempauthor2",
"actioncount":"3"
}}
]}
我需要像这样的json响应。请帮忙。