How to create a default user on meteor?

前端 未结 4 779
感动是毒
感动是毒 2021-02-19 03:39

I want to create an admin user if no users exist. I tried it on a js file inside the server folder

Meteor.startup(function () {
  if(!Meteor.users.find().count()         


        
4条回答
  •  深忆病人
    2021-02-19 04:15

    I've never found any problem on creating a user on Meteor. This is my coffeescript code:

    Meteor.startup ->
      if Meteor.users.find.count() is 0
        options =
          email: 'email@example.com'
          password: 'pass'
        Accounts.createUser(options)
    

提交回复
热议问题