chain_the_wheel
chain_the_wheel

Reputation: 177

Publish all user profiles using Meteor and Iron Router

I'm trying to publish only user profile information, which I'll be using in a member directory. This is what I'm currently doing (autopublish has been removed):

// 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({})
  }
});

This gives me all user information for all registered users, including services (hashed passwords, etc). I want to limit the data accessible on the client to the profile field only. Any help would be much appreciated.

Upvotes: 1

Views: 337

Answers (1)

David Weldon
David Weldon

Reputation: 64312

You're close - in the find options you need to specify that you are limiting the fields like this:

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

See the field specifiers documentation for more details.

Upvotes: 3

Related Questions