1

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?

1 Answer 1

2

you can try this:

app.models.Conversation.find({"where":{"participants":{"elemMatch":{"userId":1}}}}, function(err, res){
    console.log(err, res)
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.