mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
40 lines
910 B
JavaScript
40 lines
910 B
JavaScript
import { Model } from 'objection';
|
|
import path from 'path';
|
|
import BaseModel from '@/models/Model';
|
|
import ResourceFieldMetadataCollection from '@/collection/ResourceFieldMetadataCollection';
|
|
|
|
export default class ResourceFieldMetadata extends BaseModel {
|
|
/**
|
|
* Table name.
|
|
*/
|
|
static get tableName() {
|
|
return 'resource_custom_fields_metadata';
|
|
}
|
|
|
|
/**
|
|
* Override the resource field metadata collection.
|
|
*/
|
|
static get collection() {
|
|
return ResourceFieldMetadataCollection;
|
|
}
|
|
|
|
/**
|
|
* Relationship mapping.
|
|
*/
|
|
static get relationMappings() {
|
|
return {
|
|
/**
|
|
* Resource field may belongs to resource model.
|
|
*/
|
|
resource: {
|
|
relation: Model.BelongsToOneRelation,
|
|
modelBase: path.join(__dirname, 'Resource'),
|
|
join: {
|
|
from: 'resource_fields.resource_id',
|
|
to: 'resources.id',
|
|
},
|
|
},
|
|
};
|
|
}
|
|
}
|