Reputation: 805
I got a trouble to filter and group on mongodb. I really didn't undertanded how it works.
For example, in this query:
Room.aggregate(
[{
"$where": { "roomId" : myIdHere },
"$group": {
"_id": '$mobileUser.genderType',
"genderTypeCount": {
"$sum": 1
}
}
}]
Room model:
var roomModelSchema = mongoose.Schema({
roomId: String,
mobileUser: {
facebookId: String,
email: String,
name: String,
photoUrl: String,
genderType: String,
birthday: Date,
city: String
},
insertDate: Date
})
What i should do to filter by roomId and group by genderType?
Upvotes: 0
Views: 28