Reputation: 17332
I would like to transform this snippet to plain javaScript:
Meteor.startup(() => {
if (!Meteor.users.findOne({name: 'anything'})) {
let id = Accounts.createUser({
username: 'admin',
email: 'admin',
password: 'admin'
});
}
});
I think I have to transform the first line...
Upvotes: 0
Views: 269
Reputation: 144
you could change it up a little bit like:
Meteor.startup(function() {
if (Meteor.users.find().count() == 0){
Accounts.createUser({
username: 'admin',
email: 'admin',
password: 'admin'
});
}
}
Upvotes: 0
Reputation: 21005
You need to change the function definition and not use let
.
There is no sign of a this
in your code snippet, but note that this
differs between =>
and function
.
Meteor.startup(function() {
if (!Meteor.users.findOne({name: 'anything'})) {
var id = Accounts.createUser({
username: 'admin',
email: 'admin',
password: 'admin'
});
}
});
Upvotes: 5