2016-12-06 84 views
0

我知道我很接近這一點,但似乎無法理清我失蹤的東西。流星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 },

我希望得到任何幫助的人可以提供!

+0

但...'firstName'是在'profile'。 – MasterAM

+0

對不起,我對流星有點新,我怎麼寫呢?它會是c.profile.firstName? – JoethaCoder

+0

沒關係,大聲笑應該在我發佈之前測試過!謝謝你讓我檢查!哈哈 – JoethaCoder

回答

0

爲了配合這個功能本來應該:

\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 },

相關問題