I am trying to find document based on profileID in MongoDB. I want to check if string postid exists in array or not. How I can do that? I tried $all.
Mongo data:
{
"profileId": "abc",
"likedPosts": [
'post1',
'post2'
]
}
Trying to find if post1 exists in array:
findOne({
profileId
}, {
likedPosts: {
$all: ['post1']
}
}, )