Reputation: 2296
I have some existing users from a non-Meteor app. I'd like to import them and keep their _id because I reference it in other documents.
I am able to create a user like this:
if (Meteor.users.find().count() === 0) {
Accounts.createUser({
username: 'test',
email: '[email protected]',
password: 'password'
});
}
However, it doesn't seem to work to set the _id field in that block of code.
Is there a way to change the user's _id?
Upvotes: 2
Views: 268
Reputation: 85036
Try using Meteor.users.insert
instead of Accounts.createUser
. It's slightly more complicated and requires an extra step to set the password:
var newUserId = Meteor.users.insert({
_id: 'whatever',
profile : { fullname : 'test' },
email: ['[email protected]']
})
Accounts.setPassword(newUserId, 'password');
Upvotes: 1