dimanche 19 avril 2015

Mongoose query for subdocuments

I have the following scheme; its a conversation scheme with as subdocument structure a username and enabled or disabled state;



conversation = {title: "title",
users: [{"name: "a", "enabled": true}, {"name: "b", "enabled": false}]}


I want to select all the users that have an enabled state set to true. I found that $elemMatch in projection does just that, but only returns the first element... Putting $elemMatch in the query parts does not do anything...


Any help is appreciated


Aucun commentaire:

Enregistrer un commentaire