Meteor/mongodb See Available Fields For Publish?
How can I see what fields are in the users collection that are available for me to publish from the server and subscribe to from the client? I'm using Meteor.JS's Google Auth func
Solution 1:
You can inspect records in Meteor.users
on the server, for instance by logging them to the console. For example, in server.js:
Meteor.startup(function() {
Meteor.publish("nothing", function() {
if (this.userId)
console.log(Meteor.users.findOne({_id: this.userId}));
});
});
Then subscribe to this in the client:
Meteor.subscribe("nothing");
This will log the contents of the logged in user to the server console (terminal window). The reason it's in a publish method is that Meteor doesn't allow accessing the current user outside a method, so I named it "nothing" to indicate that it doesn't do anything and is just for temporary inspection purposes.
Post a Comment for "Meteor/mongodb See Available Fields For Publish?"