Meteor / MongoDB see Available fields for publication?

How can I find out which fields in the user collection are available for publication on the server and subscribe to the client? I use the Meteor.JS Google Auth features, but I use them to authorize YouTube, so the fields are not standard and not documented.

Login Code:

Meteor.loginWithGoogle({ requestPermissions: ['profile', 'email', 'https://www.googleapis.com/auth/yt-analytics.readonly', 'https://www.googleapis.com/auth/youtube'] }); 
+2
source share
1 answer

You can check the entries in Meteor.users on the server, for example, by registering them on 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 result in registration of the contents of the registered user to the server console (terminal window). The reason for this in the publishing method is that Meteor does not allow access to the current user outside the method, so I called it β€œnothing” to indicate that it does nothing and is intended only for temporary control.

+1
source

Source: https://habr.com/ru/post/953920/


All Articles