In Node with Mongoose I want to find an object in the collection Content
. It has a list of sub-documents called users
which has the properties stream
, user
and added
. I do this to get all documents with a certain user's _id
property in there users.user
field.
Content.find( { 'users.user': user._id } ).sort( { 'users.added': -1 } )
This seems to work (although I'm unsure if .sort
is really working here. However, I want to match two fields, like this:
Content.find( { 'users.user': user._id, 'users.stream': stream } } ).sort( { 'users.added': -1 } )
That does not seem to work. What is the right way to do this?
Aucun commentaire:
Enregistrer un commentaire