Javascript 如何更改Meteor.users\u id?
我有一些来自非Meteor应用程序的现有用户。我想导入它们并保留它们的_id,因为我在其他文档中引用了它 我可以创建如下用户:Javascript 如何更改Meteor.users\u id?,javascript,mongodb,meteor,Javascript,Mongodb,Meteor,我有一些来自非Meteor应用程序的现有用户。我想导入它们并保留它们的_id,因为我在其他文档中引用了它 我可以创建如下用户: if (Meteor.users.find().count() === 0) { Accounts.createUser({ username: 'test', email: 'test@example.com', password: 'password' }); } 但是,在代码块中设置_id字段似乎不起作用
if (Meteor.users.find().count() === 0) {
Accounts.createUser({
username: 'test',
email: 'test@example.com',
password: 'password'
});
}
但是,在代码块中设置_id字段似乎不起作用
有没有办法更改用户的_-id?尝试使用
Meteor.users.insert
而不是Accounts.createUser
。它稍微复杂一些,需要额外的步骤来设置密码:
var newUserId = Meteor.users.insert({
_id: 'whatever',
profile : { fullname : 'test' },
email: ['test@example.com']
})
Accounts.setPassword(newUserId, 'password');
有没有理由不只是通过MongoDB工具而不是meteor导入它们?嗯,我正在通过airtable api导入它们。谢谢。这让我可以设置_id。但是,现在我无法设置电子邮件字段,除非它在配置文件中。你知道我如何让它让我设置电子邮件字段而不将其放入个人资料中吗?这就是我使用Accounts.ui包创建新用户时的外观<代码>{“_id”:“uEfww8nKXqEFosKgA”,“用户名”:“网络磁铁”,“电子邮件”:[{“地址”:”foo@gmail.com,“已验证”:false}]}没关系。我想出来了。蒙古人在我登录时会显示我自己帐户的“电子邮件”,但不会显示我的其他帐户。这很好。