Ich habe ein Problem zu finden und Daten aus der Sammlung zu erhalten. Hier ist meine Sammlung DatenMongoDB Abfrage von dynamischen Feldern zu finden
/* 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"
}
}
}
ich alle Dokumente wollen die "points"
"type"="label"
und "values"=""
aus dem Feld haben.
Wie erreiche ich diese Liste mit find()
in mongoDB
? Hat jemand eine Idee dazu?
Würdest du vorher wissen, was A, B oder C ist? – chridam
Nein, das ist nicht behoben. Es könnte noch viel mehr geben. Es werden dynamische Felder hinzugefügt. – Meteor
@chridam aber vorschlagen, aber ich bin neu in mongoDB sein. Es wäre also großartig, wenn Sie irgendwelche Lösungen haben, die ich direkt anwenden kann. – Meteor