-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsTypeEmployee.js
52 lines (43 loc) · 1.08 KB
/
sTypeEmployee.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
const models = require("../models");
const {throwException} = require("../global/helpers");
async function getTypeEmployee(id) {
const typeEmployee = await models.TypeEmployee.findByPk(id);
if(!typeEmployee) {
throwException("E015");
}
return typeEmployee;
}
async function getPagedTypeEmployee(offset, limit) {
const {count : total, rows} = await models.TypeEmployee.findAndCountAll({
offset,
limit
});
const result = {
total,
rows,
count: rows.length
}
return result
}
async function getAllTypeEmployee() {
return await models.TypeEmployee.findAll();
}
async function createTypeEmployee(data) {
await models.TypeEmployee.create(data);
}
async function updateTypeEmployee(id, data) {
const typeEmployee = await getTypeEmployee(id);
await typeEmployee.update(data);
}
async function destroyTypeEmployee(id) {
const typeEmployee = await getTypeEmployee(id);
await typeEmployee.destroy();
}
module.exports = {
getTypeEmployee,
getAllTypeEmployee,
getPagedTypeEmployee,
createTypeEmployee,
updateTypeEmployee,
destroyTypeEmployee
}