我正在为我的Meteor应用程序编写重置数据方法,删除数据库,创建用户,为此用户生成一些虚假数据等。我正在声明使用xolvio的服务器端方法:清理器和帐户包执行此操作:
import {Accounts} from 'meteor/accounts-base';
import {resetDatabase} from 'meteor/xolvio:cleaner';
Meteor.methods({
// ..
'resetData':()=> {
resetDatabase(null, ()=>{
Accounts.onCreateUser((options, user) => console.log(user));
Accounts.createUser({
username: 'bob',
email: 'bob@kaya.com',
password: 'rastamanvibration',
profile: {
first_name: 'Bob',
last_name: 'Marley'
}
});
});
}
});
这对我来说似乎非常直接,但我收到以下错误:
Exception while invoking method 'resetData' Error: insert requires an argument
W20170622-23:28:16.817(-7)? (STDERR) at [object Object].insert (packages/mongo/collection.js:468:11)
W20170622-23:28:16.819(-7)? (STDERR) at [object Object]._.each.Mongo.Collection.(anonymous function) [as insert] (packages/aldeed_collection2-core.js:232:19)
W20170622-23:28:16.820(-7)? (STDERR) at AccountsServer.meteorInstall.node_modules.meteor.accounts-base.accounts_server.js.Ap.insertUserDoc (packages/accounts-base/accounts_server.js:1328:25)
W20170622-23:28:16.821(-7)? (STDERR) at meteorInstall.node_modules.meteor.accounts-password.password_server.js.createUser (packages/accounts-password/password_server.js:1050:25)
W20170622-23:28:16.822(-7)? (STDERR) at AccountsServer.meteorInstall.node_modules.meteor.accounts-password.password_server.js.Accounts.createUser (packages/accounts-password/password_server.js:1119:10)
W20170622-23:28:16.823(-7)?
...
答案 0 :(得分:1)
当用户未返回onCreateUser方法时会发生此错误:
Accounts.onCreateUser((user)=> {
// do things
return user;
})