2014-11-23 44 views
1

我想只發布用戶配置文件信息,我將在成員目錄中使用它。這就是我目前做的(自動發佈已被刪除):使用流星和鐵路路由器發佈所有用戶配置文件

// server/publications.js 

Meteor.publish("usersListing", function() { 
    return Meteor.users.find({}, {profile:1}); 
}); 


// routes.js (located in project root) 

this.route('users', { 
    path: '/users', 
    waitOn: function() { 
    return Meteor.subscribe("usersListing"); 
    }, 
    data: { 
    users: Meteor.users.find({}) 
    } 
}); 

這讓我對所有註冊用戶的所有用戶的信息,包括服務(哈希密碼等)。我想將客戶端上可訪問的數據限制在配置文件字段中。任何幫助將非常感激。

回答

3

你接近 - 在find選項,你需要指定要限制fields這樣的:

Meteor.users.find({}, {fields: {profile: 1}}); 

有關詳細信息,請參閱field specifiers documentation

+0

這樣做 - 非常感謝! – 2014-11-23 15:25:29