File tree 1 file changed +31
-5
lines changed
1 file changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,32 @@ class UserRoleService {
25
25
return data
26
26
}
27
27
28
+ /**
29
+ *
30
+ * @param arrayFormData - formData array []
31
+ * @param txn - Transaction
32
+ */
33
+ public static async bulkCreate (
34
+ arrayFormData : UserRoleAttributes [ ] ,
35
+ txn ?: Transaction
36
+ ) {
37
+ const newFormData = [ ]
38
+ if ( Array . isArray ( arrayFormData ) ) {
39
+ for ( let i = 0 ; i < arrayFormData . length ; i += 1 ) {
40
+ const formData = arrayFormData [ i ]
41
+
42
+ const value = useValidation ( schema . create , formData )
43
+ newFormData . push ( value )
44
+ }
45
+ }
46
+
47
+ const data = await UserRole . bulkCreate ( newFormData , {
48
+ transaction : txn ,
49
+ } )
50
+
51
+ return data
52
+ }
53
+
28
54
/**
29
55
*
30
56
* @param formData
@@ -51,7 +77,7 @@ class UserRoleService {
51
77
await UserRole . destroy ( {
52
78
where : {
53
79
UserId : {
54
- [ Op . in ] : id ,
80
+ [ Op . in ] : [ id ] ,
55
81
} ,
56
82
} ,
57
83
} )
@@ -60,16 +86,16 @@ class UserRoleService {
60
86
/**
61
87
*
62
88
* @param id
63
- * @param roles Array of String
89
+ * @param Roles Array of String
64
90
* @example
65
- * roles = ['id_1', 'id_2']
91
+ * Roles = ['id_1', 'id_2']
66
92
*/
67
- public static async deleteNotInRoleId ( id : string , roles : [ ] ) {
93
+ public static async deleteNotInRoleId ( id : string , Roles : [ ] ) {
68
94
await UserRole . destroy ( {
69
95
where : {
70
96
UserId : id ,
71
97
RoleId : {
72
- [ Op . notIn ] : roles ,
98
+ [ Op . notIn ] : Roles ,
73
99
} ,
74
100
} ,
75
101
} )
You can’t perform that action at this time.
0 commit comments