fix: hotbugs in multi-tenant arch.

This commit is contained in:
Ahmed Bouhuolia
2020-04-22 01:12:24 +02:00
parent 8f588ffc51
commit 1e13aa16ac
6 changed files with 33 additions and 80 deletions

View File

@@ -1,39 +0,0 @@
import { Model } from 'objection';
import TenantModel from '@/models/TenantModel';
export default class ItemMetadata extends TenantModel {
/**
* Table name
*/
static get tableName() {
return 'items_metadata';
}
/**
* Timestamp columns.
*/
static get hasTimestamps() {
return ['created_at', 'updated_at'];
}
/**
* Relationship mapping.
*/
static get relationMappings() {
const Item = require('@/models/Item');
return {
/**
* Item category may has many items.
*/
items: {
relation: Model.BelongsToOneRelation,
modelBase: this.relationBindKnex(Item.default),
join: {
from: 'items_metadata.item_id',
to: 'items.id',
},
},
};
}
}

View File

@@ -1,5 +1,3 @@
import { Model } from 'objection';
import path from 'path';
import TenantModel from '@/models/TenantModel';
import ResourceFieldMetadataCollection from '@/collection/ResourceFieldMetadataCollection';
@@ -17,23 +15,4 @@ export default class ResourceFieldMetadata extends TenantModel {
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',
},
},
};
}
}