0
我试图用collection2
从其他集合中抽取array
。我已经能够使用用户下面的示例对象做到这一点:流星交叉收集阵列
\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 },
我愿做相同的,但对于对象的数组。这里是源数据的样子:
{
"_id": "xDkso4FXHt63K7evG",
"AboveGroundSections": [{
"sectionName": "one"
}, {
"sectionName": "two"
}],
"AboveGroundItems": [{
"itemSection": "one",
"itemDescription": "dfgsdfg",
"itemCode": "dsfgsdg"
}, {
"itemSection": "two",
"itemDescription": "sdfgsdfg",
"itemCode": "sdfgsdgfsd"
}]
}
这里是我的功能是什么样子:
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
}
});
}
}
},
我知道这一点,它只是不为我拉数据。我相信,我只是缺少一些小东西。我正试图拉取AboveGroundSection
阵列内的所有对象。