Meteor Accounts.createUser不';不保存配置文件
我的Meteor Accounts.createUser不';不保存配置文件,meteor,accounts,createuser,Meteor,Accounts,Createuser,我的server/fixtures.js文件中有以下代码: var userId = Accounts.createUser({ username: "tester", email: "a@b.com", password: "foobar", profile: { name: "Max" } }); var user = Meteor.users.findOne({_id: userId}); console.log(user.profile.name); 现在,当我运行me
server/fixtures.js
文件中有以下代码:
var userId = Accounts.createUser({
username: "tester",
email: "a@b.com",
password: "foobar",
profile: { name: "Max" }
});
var user = Meteor.users.findOne({_id: userId});
console.log(user.profile.name);
现在,当我运行meteor时,它会记录未定义的代码。我做错了什么?我认为您需要使用Meteors出版物和订阅。检查这个 更多信息 示例:
if (Meteor.isServer){
Meteor.publish('userdata', function() {
if(!this.userId) return null;
return Meteor.users.find( this.userId );
});
}
if (Meteor.isClient){
Meteor.subscribe('userdata');
console.log(Meteor.user());
}
我很确定我已经在某个地方定义了一个回调函数,这就是原因。我的错 因此,问题是console.log在服务器上不可用(该文件根据Meteor目录约定在服务器上运行)。如果要登录到服务器控制台,可以使用与console.log相同的
Meteor.\u debug()
。您可能还想考虑在<代码>流星启动(函数({)})中包覆代码;<代码>块,以便在服务器启动时立即运行 console.log在服务器上可用。您可以在运行meteor服务器的窗口中看到输出。我自己回答了这个问题,我假设我在某处定义了Accounts.onCreateUser回调。