Skip to content

Commit db33a36

Browse files
committed
feat: add delete by user ids service user role
1 parent dd4c7af commit db33a36

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/controllers/UserRole/service.ts

+21-5
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,8 @@ class UserRoleService {
5555
/**
5656
*
5757
* @param formData
58-
* @param txn Transaction Sequelize
5958
*/
60-
public static async findOrCreate(
61-
formData: UserRoleAttributes,
62-
txn?: Transaction
63-
) {
59+
public static async findOrCreate(formData: UserRoleAttributes) {
6460
const values = useValidation(schema.create, formData)
6561

6662
const data = await UserRole.findOrCreate({
@@ -73,6 +69,7 @@ class UserRoleService {
7369
/**
7470
*
7571
* @param id
72+
* @param force
7673
*/
7774
public static async deleteByUserId(id: string, force?: boolean) {
7875
const isForce = validateBoolean(force)
@@ -87,10 +84,29 @@ class UserRoleService {
8784
})
8885
}
8986

87+
/**
88+
*
89+
* @param id
90+
* @param force
91+
*/
92+
public static async deleteByUserIds(ids: Array<string>, force?: boolean) {
93+
const isForce = validateBoolean(force)
94+
95+
await UserRole.destroy({
96+
where: {
97+
UserId: {
98+
[Op.in]: ids,
99+
},
100+
},
101+
force: isForce,
102+
})
103+
}
104+
90105
/**
91106
*
92107
* @param id
93108
* @param Roles Array of String
109+
* @param force
94110
* @example
95111
* Roles = ['id_1', 'id_2']
96112
*/

0 commit comments

Comments
 (0)