创建用户时Meteor分配\u id
我想在创建meteor用户时分配他们的_id<代码>Meteor.createUser()似乎不允许这样做创建用户时Meteor分配\u id,meteor,Meteor,我想在创建meteor用户时分配他们的_idMeteor.createUser()似乎不允许这样做 还有其他方法吗?Accounts.onCreateUser存在于服务器上,允许在插入用户文档之前对其进行自定义。下面的代码修改文档,新用户出现在数据库中,客户端上的用户使用定制的_id登录 //in server js code Accounts.onCreateUser( function( options, user){ user._id = 'myId' + Math.floor( Ma
还有其他方法吗?Accounts.onCreateUser存在于服务器上,允许在插入用户文档之前对其进行自定义。下面的代码修改文档,新用户出现在数据库中,客户端上的用户使用定制的_id登录
//in server js code
Accounts.onCreateUser( function( options, user){
user._id = 'myId' + Math.floor( Math.random() * 1000 ) + 1;
if (options.profile)
user.profile = options.profile; //careful not to drop the profile if it exists
return user;
});
函数文档和一个非常类似的示例如下-