流星AutoForm添加用户选择
问题描述:
我知道我很接近这一点,但似乎无法理清我失踪的东西。流星AutoForm添加用户选择
我想将所有用户作为选项添加到autoform quickform中的选择。我能够使用另一个集合,但是当我为用户使用相同的代码时,该值显示为_id,但无法返回标签。
这里是我的用户的结构:
{
"_id": "s3EYXXK5N8NExHrke",
"emails": [{
"address": "[email protected]",
"verified": false
}],
"profile": {
"firstName": "Joe",
"lastName": "Smuck",
"licenseNumber": "1234567",
"accountType": "administrator"
},
"roles": [
"administrator"
],
"createdAt": "2016-12-02T21:51:11.844Z",
"services": {
"password": {
"bcrypt": "$2a$10$NheMU2x/8RvcMxNHeWxbQOpHlWAQmopvk3KrMG9oo5ruTir2ARf8W"
},
"resume": {
"loginTokens": [{
"when": "2016-12-02T21:51:11.948Z",
"hashedToken": "8PktpX6kqK6yM+LMrqRaoqXCbwYG6gdO7MH9V/Th/dI="
}, {
"when": "2016-12-03T03:01:06.600Z",
"hashedToken": "ihn93xaN6rE8fvwBHZ3p8H6z0T7o7WChQoqD4dlkSpw="
}, {
"when": "2016-12-05T14:37:41.147Z",
"hashedToken": "7QE7HxcmDrZPFI3Omn5c1o73pMa3XzOBj3RbquCmo6U="
}]
}
}
}
我想打印的firstName的选择。下面是模式我现在有:
\t inspector: {
\t type: String,
\t label: "Inspector",
\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.firstName,
\t value: c._id
\t };
\t });
\t }
\t }
\t },
我希望得到任何帮助的人可以提供!
答
为了配合这个功能本来应该:
\t inspector: {
\t type: String,
\t label: "Inspector",
\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,
\t value: c._id
\t };
\t });
\t }
\t }
\t },
但...'firstName'是在'profile'。 – MasterAM
对不起,我对流星有点新,我怎么写呢?它会是c.profile.firstName? – JoethaCoder
没关系,大声笑应该在我发布之前测试过!谢谢你让我检查!哈哈 – JoethaCoder