Unable to publish Current User fields

I have turned off auto publish in my App and am trying to Publish User Data that is submitted after user is creates. Following is my Publishing code on server side …

Meteor.publish("userData", function () {
  if (this.userId) {
    return Meteor.users.find({_id: this.userId},
                             {fields: {'services':1, 'firstLogin':0, 'verified':1, 'skills':1, 'role':1}});
  } else {

And following is my Subscription code.


But all I see are _id, firstLogin, services and profile. I can see rest of the fields when i do db.users.find() but I can access them in browser console.

Any help will be much appreciated. Thanks.


Do you wait for the subscription to be ready before you try to access the data?

I do have this in my router.js

  layoutTemplate:  "layout",
  loadingTemplate: "loading",
  notFoundTemplate: "notFound",
  waitOn: function() { return Meteor.subscribe('userData'); }

Why not just make it automatic using a null publication?

Meteor.publish(null, function () {
  return Meteor.users.find({
    _id: this.userId
  }, {
    fields: {
      services: 1,
      verified: 1,
      skills: 1,
      role: 1
}, { is_auto: true });

Then you can just use Meteor.user() and see this data.


Sorry, I don’t user Iron Router and cannot check if this code works.

You’re a legend mate. Thank You!!
This has been bugging me all day. I can finally get some food :slight_smile:

Hey, I need your help again. I made the user Data publication NULL as you suggested and it was working perfectly. I could turn on and off the fields I wanted to see. But that was all on localhost. I just deployed the App to the Meteor server and once again, all I see are ID, Profile and Services.

Any ideas what could be causing the changes after deploying?