2014-04-26 55 views
1

我使用的賬戶,谷歌軟件包註冊用戶Meteor.users.find()。fetch()方法返回一個用戶

我有多個用戶存儲在蒙戈

db.users.find() 

{ "_id" : "av8Dxwkf5BC59fzQN", "profile" : { "avatar" : "https://lh3.googleusercontent.com/-rREuhQEDLDY/AAAAAAAAAAI/AAAAAAAADNs/x764bovDfQo/photo.jpg", "email" : "[email protected]", "name" : "Luke Fender", "room" : "2" }, "services" : { "resume" : { "loginTokens" : [ { "when" : ISODate("2014-04-26T19:34:52.195Z"), "hashedToken" : "8na48dlKQdTnmPEvvxBrWOm3FQcWFnDE0VnGfL4hlhM=" } ] } } } 

{ "_id" : "6YJKb7umMs2ycHCPx", "profile" : { "avatar" : "https://lh3.googleusercontent.com/-rREuhQEDLDY/AAAAAAAAAAI/AAAAAAAADNs/x764bovDfQo/photo.jpg", "email" : "[email protected]", "name" : "Luke Fender", "room" : "2" }, "services" : { "resume" : { "loginTokens" : [ { "when" : ISODate("2014-04-26T19:35:00.185Z"), "hashedToken" : "d/vnEQMRlc4VI8pXcYmBvB+MqQLAFfAKsKksjCXapfM=" } ] } } } 

Meteor.users.find().fetch()回報文檔僅登錄用戶 - 不應該返回整個集合嗎?其他用戶默認情況下是不公開的嗎?

回答

4

這是默認行爲。你只能看到你登錄的人。

您可以製作自定義發佈功能來發布自定義子集/您想要的內容。在下面我發佈所有用戶的例子(僅輪廓場)

服務器端代碼

Meteor.publish('users', function() { 
    return Meteor.users.find({}, {fields:{profile: true}}); 
}); 

客戶端代碼

Meteor.subscribe("users"); 

您可能希望將這些改變,以只發布與用戶相關的內容。如果你有超過100個用戶,開始浪費它們將它們全部發布到客戶端。

+0

我剛剛解決了這個問題,當你評論。這是問題 - 我沒有從我的發佈呼叫中返回所有用戶。 – lfender6445