-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.js
More file actions
40 lines (38 loc) · 889 Bytes
/
seed.js
File metadata and controls
40 lines (38 loc) · 889 Bytes
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
const models = require('./app/models');
const User = models.User;
const Role = models.Role;
const Permission = models.Permission;
const RoleUsers = models.RoleUsers;
var bcrypt = require('bcryptjs')
const Sequelize = require('sequelize');
const Op = Sequelize.Op
var allPermissions = []
User.findAll({
where: {
id: {
[Op.gte]: 2
}
}
})
.then(users => {
users.forEach(function (user) {
Role.findByPk(1)
.then(thisRole => {
user.setRoles(thisRole).then(()=>{})
})
.catch((err)=>{
console.log(err)
})
})
return users
})
.then(users => {
Permission.findAll().then((auxPermissions)=>{
users.forEach(function (user) {
user.setPermissions(auxPermissions).then(()=>{})
})
})
})
.catch((err)=>{
console.log(err)
})