I'm new to loopback, however I followed the steps to install and scaffold my folder (loopback-server), inside server/boot/ I created one file script.js and included the following code:
module.exports = function(app) {
var MongoDB = app.dataSources.MongoDB;
MongoDB.automigrate('Customer', function(err) {
if (err) throw (err);
var Customer = app.models.Customer;
Customer.create([
{username: 'admin', email: 'admin@admin.com', password: 'abcdef'},
{username: 'user', email: 'muppala@ust.hk', password: 'abcdef'}
], function(err, users) {
if (err) throw (err);
var Role = app.models.Role;
var RoleMapping = app.models.RoleMapping;
//create the admin role
Role.create({
name: 'admin'
}, function(err, role) {
if (err) throw (err);
//make admin
role.principals.create({
principalType: RoleMapping.USER,
principalId: users[0].id
}, function(err, principal) {
if (err) throw (err);
});
});
});
});
};
Now I'm getting this error:
I commented this file out and didn't get that error. By the way, I tried to change the keys and values of {username: 'admin',..} and Role.create({name: 'admin'},.... but either doesn't work or it works but I can't login as admin.