Meteor.users.find().fetch() returns single user

meteor

Solution

This is the default behaviour. You can only see who you're logged in as.

You can make a custom publish function to publish a custom subset/what you want. In the example below I publish all the users (only the profile field)

Server side code

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

Client side code

Meteor.subscribe("users");

You might want to alter these to only publish what is relevant to the user. If you have over 100 users this begins to get wasteful to publish all of them to the client.

Problem

I am using accounts-google package to register users I have multiple users stored in mongo ``` db.users.find() { "_id" : "av8Dxwkf5BC59fzQN", "profile" : { "avatar" : "https://lh3.googleusercontent.com/-rREuhQEDLDY/AAAAAAAAAAI/AAAAAAAADNs/x764bovDfQo/photo.jpg", "email" : "lfender6445@gmail.com", "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" : "lfender6445@gmail.com", "name" : "Luke Fender", "room" : "2" }, "services" : { "resume" : { "loginTokens" : [ { "when" : ISODate("2014-04-26T19:35:00.185Z"), "hashedToken" : "d/vnEQMRlc4VI8pXcYmBvB+MqQLAFfAKsKksjCXapfM=" } ] } } } ``` But `Meteor.users.find().fetch()` returns document for logged in user only - shouldn't this return entire collection? Are the other users somehow private by default?

Original source