mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-27 18:19:48 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
39
packages/server/src/modules/Roles/models/Role.model.ts
Normal file
39
packages/server/src/modules/Roles/models/Role.model.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Model, mixin } from 'objection';
|
||||
import { TenantBaseModel } from '@/modules/System/models/TenantBaseModel';
|
||||
import { RolePermission } from './RolePermission.model';
|
||||
|
||||
export class Role extends TenantBaseModel {
|
||||
name: string;
|
||||
description: string;
|
||||
slug: string;
|
||||
predefined: boolean;
|
||||
permissions: Array<RolePermission>;
|
||||
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'roles';
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const { RolePermission } = require('./RolePermission.model');
|
||||
|
||||
return {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
permissions: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: RolePermission,
|
||||
join: {
|
||||
from: 'roles.id',
|
||||
to: 'role_permissions.roleId',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user