[英]not able to fetch using $and in mongo db
I'm trying to use $and in mongodb stitch function to get data using 2 different condition我正在尝试使用 $and 在 mongodb 缝合 function 中使用 2 个不同的条件获取数据
data = col.find( { $and: [ { "title": { title } }, { "address.countryName": { country } } ] } ).toArray;
but this shows $undefined:true in response.但这显示 $undefined:true 作为响应。
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
}
]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.