mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
39 lines
733 B
JavaScript
39 lines
733 B
JavaScript
import path from 'path';
|
|
import { Model } from 'objection';
|
|
import BaseModel from '@/models/Model';
|
|
|
|
export default class ItemMetadata extends BaseModel {
|
|
/**
|
|
* Table name
|
|
*/
|
|
static get tableName() {
|
|
return 'items_metadata';
|
|
}
|
|
|
|
/**
|
|
* Timestamp columns.
|
|
*/
|
|
static get hasTimestamps() {
|
|
return ['created_at', 'updated_at'];
|
|
}
|
|
|
|
/**
|
|
* Relationship mapping.
|
|
*/
|
|
static get relationMappings() {
|
|
return {
|
|
/**
|
|
* Item category may has many items.
|
|
*/
|
|
items: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelBase: path.join(__dirname, 'Item'),
|
|
join: {
|
|
from: 'items_metadata.item_id',
|
|
to: 'items.id',
|
|
},
|
|
},
|
|
};
|
|
}
|
|
}
|