mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
add server to monorepo.
This commit is contained in:
46
packages/server/src/models/ViewRole.ts
Normal file
46
packages/server/src/models/ViewRole.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Model } from 'objection';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
|
||||
export default class ViewRole extends TenantModel {
|
||||
|
||||
/**
|
||||
* Virtual attributes.
|
||||
*/
|
||||
static get virtualAttributes() {
|
||||
return ['comparators'];
|
||||
}
|
||||
|
||||
static get comparators() {
|
||||
return [
|
||||
'equals', 'not_equal', 'contains', 'not_contain',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Table name.
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'view_roles';
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const View = require('models/View');
|
||||
|
||||
return {
|
||||
/**
|
||||
* View role model may belongs to view model.
|
||||
*/
|
||||
view: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: View.default,
|
||||
join: {
|
||||
from: 'view_roles.viewId',
|
||||
to: 'views.id',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user