-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
75 lines (67 loc) · 1.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict';
//dependencies
const _ = require('lodash');
const async = require('async');
const mongoose = require('mongoose');
const Role = mongoose.model('Role');
const Party = mongoose.model('Party');
function registerParties(role, done) {
//default parties
let parties = [{
email: 'lallyelias87@gmail.com',
password: 'open311@qwerty',
name: 'Lally Elias',
sipNumber: '1000',
phone: '255714095061',
roles: [role]
}, {
email: 'kbng.moses@gmail.com',
password: 'open311@qwerty',
name: 'Moses Kabungo',
phone: '255753111039',
roles: [role]
}, {
email: 'nadhiru.saidi@gmail.com',
password: 'open311@qwerty',
name: 'Nadhiru Saidi',
phone: '255713970405',
roles: [role]
}, {
email: 'emilrke@gmail.com',
password: 'open311@qwerty',
name: 'Emily Kimario',
phone: '255713251899',
roles: [role]
}, {
email: 'joachimm3@gmail.com',
password: 'open311@qwerty',
name: 'Joachim Mangilima',
phone: '255713111111',
roles: [role]
}, {
email: 'jeanbarroca@gmail.com',
password: 'open311@qwerty',
name: 'Jean Barroca',
phone: '255765111111',
roles: [role]
}];
parties = _.map(parties, function (party) {
return function (next) {
Party.register(party, next);
};
});
async.parallel(parties, done);
}
//after data seeding logics
module.exports = function (done) {
async.waterfall([
function createRoles(next) {
Role.findOne({
name: 'Administrator'
}, next);
},
function createParty(role, next) {
registerParties(role, next);
}
], done);
};