如何查看用户集合中的哪些字段可供我从服务器发布和从客户端订阅?我正在使用 Meteor.JS 的 Google Auth 函数,但我正在使用它们来授权 YouTube,因此这些字段不是标准的或记录的。
登录码:
Meteor.loginWithGoogle({
requestPermissions: ['profile', 'email', 'https://www.googleapis.com/auth/yt-analytics.readonly', 'https://www.googleapis.com/auth/youtube']
});
最佳答案
您可以检查服务器上 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”以表明它什么都不做,只是为了临时检查目的。
关于javascript - Meteor/MongoDB 看到可用的发布字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14104391/