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