mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
34 lines
685 B
JavaScript
34 lines
685 B
JavaScript
import path from 'path';
|
|
import { Model } from 'objection';
|
|
import TenantModel from '@/models/TenantModel';
|
|
|
|
export default class ItemCategory extends TenantModel {
|
|
/**
|
|
* Table name.
|
|
*/
|
|
static get tableName() {
|
|
return 'items_categories';
|
|
}
|
|
|
|
/**
|
|
* Relationship mapping.
|
|
*/
|
|
static get relationMappings() {
|
|
const Item = require('@/models/Item');
|
|
|
|
return {
|
|
/**
|
|
* Item category may has many items.
|
|
*/
|
|
items: {
|
|
relation: Model.HasManyRelation,
|
|
modelClass: this.relationBindKnex(Item.default),
|
|
join: {
|
|
from: 'items_categories.id',
|
|
to: 'items.categoryId',
|
|
},
|
|
},
|
|
};
|
|
}
|
|
}
|