Reputation: 1247
What is the proper way to seed the database with an initial admin/root user in a User model in Sails if one does not exist upon launch?
Upvotes: 1
Views: 1106
Reputation: 1247
Solution: I found the solution to this problem. Since models are created before bootstrap.js is run in the config folder, I can simply check if a User model with ID "root" already exists, and if not, use User.create() to create the user.
Long story short, just create the user in config/bootstrap.js BEFORE the callback cb().
Upvotes: 1