我在mongodb中有一个集合。这是链接https://mongoplayground.net/p/aDMwOc5Wal4。 我需要所有的狗,橘子和红色蔬菜。
我正在尝试查询但没有找到方法。
答案 0 :(得分:2)
您可以尝试一下。
db.collection.find({
$or: [
{
"type": {
"$in": [
"Dog",
"Orange"
]
}
},
{
$and: [
{
"color": {
"$in": [
"red"
]
},
"cat": {
"$in": [
"Vegetable"
]
}
}
]
}
]
})