mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-02-15 04:42:05 +00:00
31 lines
801 B
JavaScript
31 lines
801 B
JavaScript
|
/**
|
||
|
* Populate DB with sample data on server start
|
||
|
* to disable, edit config/environment/index.js, and set `seedDB: false`
|
||
|
*/
|
||
|
|
||
|
'use strict';
|
||
|
import User from '../api/user/user.model';
|
||
|
import config from './environment/';
|
||
|
|
||
|
export default function seedDatabaseIfNeeded() {
|
||
|
if(config.seedDB) {
|
||
|
User.find({}).remove()
|
||
|
.then(() => {
|
||
|
User.create({
|
||
|
provider: 'local',
|
||
|
name: 'Test User',
|
||
|
email: 'test@example.com',
|
||
|
password: 'test'
|
||
|
}, {
|
||
|
provider: 'local',
|
||
|
role: 'admin',
|
||
|
name: 'Admin',
|
||
|
email: 'admin@example.com',
|
||
|
password: 'admin'
|
||
|
})
|
||
|
.then(() => console.log('finished populating users'))
|
||
|
.catch(err => console.log('error populating users', err));
|
||
|
});
|
||
|
}
|
||
|
}
|