如何查看users集合中哪些字段可供我从服务器发布和从客户端订阅?我使用的是Metor.JS的Google Auth函数,但我使用它们来授权YouTube,这样字段就不是标准的或有文档记录的。
登录代码:
Meteor.loginWithGoogle({
requestPermissions: ['profile', 'email', 'https://www.googleapis.com/auth/yt-analytics.readonly', 'https://www.googleapis.com/auth/youtube']
});发布于 2013-01-01 03:16:43
您可以在服务器上检查Meteor.users中的记录,例如,通过将它们记录到控制台。例如,在server.js中:
Meteor.startup(function() {
Meteor.publish("nothing", function() {
if (this.userId)
console.log(Meteor.users.findOne({_id: this.userId}));
});
});然后在客户端订阅:
Meteor.subscribe("nothing");这会将登录用户的内容记录到服务器控制台(终端窗口)。它在publish方法中的原因是Meteor不允许访问方法外部的当前用户,所以我将其命名为"nothing“,以表明它不做任何事情,只是为了临时检查目的。
https://stackoverflow.com/questions/14104391
复制相似问题