I have data like this:
{
"profileID": "123456789",
"myArray": [
{
"read": false
},
{
"read": true
},
{
"read": false
},
{
"read": true
}
]
}
I want to be able to get the count of: myArray where read is false. I need to do this on Mongoose. In the example above, the return I want is 2.
My findOne is like below:
userModel.findOne({'profileID': 123456789}, function(err, myArray) {
//Code to run here
});
I can manually run through the response and make my count that way but that will be very ineffeciant.
How do I get the count of the user's myArray's unread values on the database level?
Thanks