I have the following code
//My search array
var charArray=['a','b','c']
{
name: 'object1',
myChar: ['a','v','x']
}
{
name: 'object2',
myChar: ['f','h','y']
}
I want to get the object which contains a value in its attribute.
I hope to get the first object using this:
db.getCollection('myObjects').find({
'myChar':{
$in:charArray
}
})
The response is null. In fact I tried using $elemMatch without success
db.getCollection('myObjects').find({
'myChar':{
$elemMatch: {$in: charArray}
}
})