I have a document :
{
_id: 98556a665626a95a655a,
first_name: 'Panda',
last_name: 'Panda,
notifications: [{
_id: '',
// ...
}]
}
I want to return the following response :
{
_id: 98556a665626a95a655a,
first_name: 'Panda',
last_name: 'Panda',
notifications: 2
}
The problem is about notifications count field,
I used Mongoose NodeJS package and I tried the following :
UserDBModel.findOne({_id: uid}, {notifications: {$size: '$notifications'}}, function(err, user){ });
But it seems to not work. Someone can help me ? :)
Thanks in advance.