0
試圖找到一種方法來達到子子字段之間的動態子字段。不知道如何到達那裏。尋找像$用於數組的東西。MongoDB通過嵌套動態子字段進行搜索
我的數據結構如下所示
{
_id: ObjectId("59355deee13f1a1260f17421"),
product: {
shirt: {
color: "black"
}
}
},
{
_id: ObjectId("59355deee13f1a1260f17422"),
product: {
top: {
color: "red"
}
}
},
{
_id: ObjectId("59355deee13f1a1260f17423"),
product: {
shoes: {
color: "black"
}
}
},
{
_id: ObjectId("59355deee13f1a1260f17424"),
product: {
belt: {
color: "brown7"
}
}
},
尋找的
db.things.find({product.$.color: "black"})
謝謝!謝謝 !!謝謝 !!! 正是我在找的東西。 –
現在我正在尋找適合在芒果糖 –
這很高興它幫助.. !!。你能夠適應這個貓鼬? –