Reputation: 1369
I have a table Conversation
with property :
"participants": {
"type": [
"object"
],
"required": true
}
and the dataSource
is MongoDb. I inserted data in format:
{participants:[{userId:1},{userId:2}]}
.
Now I want to find all conversation which userId 1 is in.
What i did is using this filter: {where:{participants:{userId:1}}}
but it doesn't work like MongoDb query. How can I achieve it?
Upvotes: 1
Views: 1065
Reputation: 2441
you can try this:
app.models.Conversation.find({"where":{"participants":{"elemMatch":{"userId":1}}}}, function(err, res){
console.log(err, res)
})
Upvotes: 2