I'm trying to use $and in mongodb stitch function to get data using 2 different condition
data = col.find( { $and: [ { "title": { title } }, { "address.countryName": { country } } ] } ).toArray;
but this shows $undefined:true in response.
please guide what is wrong in here
You need to remove {}
in the condition's value
db.getCollection('test').find({
$and: [
{
"title": 'title' --> Here
},
{
"address.countryName": 'country' --> Here
}
]
})