2
我有一個問題可以從集合中查找並獲取數據。下面是我收集的數據MongoDB查詢從動態字段中查找
/* 1 */
{
"_id" : 1,
"name" : "sue",
"age" : 19,
"type" : 1,
"points" : {
"A" : {
"type" : "label",
"values" : "abc"
},
"B" : {
"mandatory" : false,
"type" : "text"
},
"C" : {
"mandatory" : false,
"type" : "text"
}
}
}
/* 2 */
{
"_id" : 2,
"name" : "bob",
"age" : 42,
"type" : 1,
"points" : {
"B" : {
"type" : "label",
"values" : ""
},
"C" : {
"mandatory" : false,
"type" : "text"
}
}
}
/* 3 */
{
"_id" : 3,
"name" : "ahn",
"age" : 22,
"type" : 2,
"points" : {
"A" : {
"type" : "label",
"values" : "abc"
},
"C" : {
"mandatory" : false,
"type" : "text"
}
}
}
/* 4 */
{
"_id" : 4,
"name" : "xi",
"age" : 34,
"type" : 2,
"points" : {
"A" : {
"type" : "label",
"allowedValues" : "abc"
},
"C" : {
"mandatory" : false,
"type" : "text"
}
}
}
/* 5 */
{
"_id" : 5,
"name" : "xyz",
"age" : 23,
"type" : 2,
"points" : {
"B" : {
"mandatory" : false,
"type" : "text"
},
"C" : {
"values" : "C",
"type" : "text"
}
}
}
/* 6 */
{
"_id" : 6,
"name" : "abc",
"age" : 43,
"type" : 1,
"points" : {
"A" : {
"type" : "label",
"values" : "abc"
},
"B" : {
"mandatory" : false,
"type" : "text"
}
}
}
我想這有"type"="label"
和"values"=""
從外地"points"
的所有文件。
如何使用find()
在mongoDB
中實現此列表?有沒有人有這個想法?
您知道A,B或C是事先知道嗎? – chridam
不,這不是修復..可能還有更多。它的動態字段將被添加。 – Meteor
@chridam但暗示,但我是新的在mongoDB。所以,如果你有任何我可以直接申請的解決方案,那將是非常好的。 – Meteor