Skip to content

Commit

Permalink
fix: user role service
Browse files Browse the repository at this point in the history
  • Loading branch information
masb0ymas committed Nov 23, 2020
1 parent 5c13139 commit 6e84435
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/controllers/UserRole/service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import models from 'models'
import db from 'models/_instance'
import useValidation from 'helpers/useValidation'
Expand All @@ -13,7 +12,9 @@ const { UserRole } = models

class UserRoleService {
/**
* Create User Role
*
* @param formData
* @param txn Transaction Sequelize
*/
public static async create(formData: UserRoleAttributes, txn?: Transaction) {
const values = useValidation(schema.create, formData)
Expand All @@ -25,7 +26,9 @@ class UserRoleService {
}

/**
* Find Or Create User Role
*
* @param formData
* @param txn Transaction Sequelize
*/
public static async findOrCreate(
formData: UserRoleAttributes,
Expand All @@ -41,7 +44,8 @@ class UserRoleService {
}

/**
* Delete UserRole by UserId
*
* @param id
*/
public static async deleteByUserId(id: string) {
await UserRole.destroy({
Expand All @@ -54,7 +58,11 @@ class UserRoleService {
}

/**
* Delete UserRole not In RoleId
*
* @param id
* @param roles Array of String
* @example
* roles = ['id_1', 'id_2']
*/
public static async deleteNotInRoleId(id: string, roles: []) {
await UserRole.destroy({
Expand Down

0 comments on commit 6e84435

Please sign in to comment.