Answer the question
In order to leave comments, you need to log in
How to fix $cond?
{
$group: {
'_id': '$ft',
'orig_id': {
$last: '$_id'
},
'from': {
$last: '$from'
},
'to': {
$last: '$to'
},
'msg': {
$last: '$msg'
},
'date': {
$last: '$date'
},
'unreaded': {
$sum: {
$cond: [{
$ne: ['$read', 142]
}, 1, 0]
}
}
}
}
{ "_id" : ObjectId("598308c3036f7311e3ddcfec"), "from" : 202, "to" : 142, "msg" : "123", "date" : ISODate("2017-08-03T11:28:03.462Z"), "read" : [ 202, 142 ], "favor" : [ ] }
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question