Ich versuche, eine array
aus einer anderen Sammlung mit collection2
zu ziehen. Ich konnte dies mit Objekten tun, das folgende Beispiel für Benutzer mit:Meteor Kreuz Sammlung Arrays
\t users: {
\t type: String,
\t label: "Inspector",
\t optional: true,
\t autoform: {
\t firstOption: 'Choose an Inspector',
\t options: function() {
\t return Meteor.users.find({}, {
\t sort: {
\t profile: 1,
\t firstName: 1
\t }
\t }).map(function(c) {
\t return {
\t label: c.profile.firstName + " " + c.profile.lastName,
\t value: c._id
\t };
\t });
\t }
\t }
\t },
Ich möchte das gleiche tun, sondern für eine Reihe von Objekten. Hier ist, was die Quelldaten wie folgt aussieht:
{
"_id": "xDkso4FXHt63K7evG",
"AboveGroundSections": [{
"sectionName": "one"
}, {
"sectionName": "two"
}],
"AboveGroundItems": [{
"itemSection": "one",
"itemDescription": "dfgsdfg",
"itemCode": "dsfgsdg"
}, {
"itemSection": "two",
"itemDescription": "sdfgsdfg",
"itemCode": "sdfgsdgfsd"
}]
}
Hier ist, was meine Funktion wie folgt aussieht:
agSection: {
type: String,
optional: true,
autoform: {
firstOption: 'Select A Section Type',
options: function() {
return TemplateData.find({}, {
sort: {
AboveGroundSections: 1,
sectionName: [0]
}
}).map(function(c) {
return {
label: c.AboveGroundSections.sectionName,
value: c.AboveGroundSections.sectionName
}
});
}
}
},
ich das weiß, dann ist es einfach nicht ziehe die Daten für mich. Ich bin mir sicher, ich vermisse nur etwas Kleines. Ich versuche, alle Objekte innerhalb des AboveGroundSection
Arrays zu ziehen.