WIP server side.

This commit is contained in:
Ahmed Bouhuolia
2020-01-22 02:09:45 +02:00
parent de905d7e7c
commit 488709088b
123 changed files with 14885 additions and 771 deletions

View File

@@ -1,23 +1,38 @@
import bookshelf from './bookshelf';
const ItemMetadata = bookshelf.Model.extend({
import path from 'path';
import { Model } from 'objection';
import BaseModel from '@/models/Model';
export default class ItemMetadata extends BaseModel {
/**
* Table name
*/
tableName: 'items_metadata',
static get tableName() {
return 'items_metadata';
}
/**
* Timestamp columns.
*/
hasTimestamps: ['created_at', 'updated_at'],
static get hasTimestamps() {
return ['created_at', 'updated_at'];
}
/**
* Item category may has many items.
* Relationship mapping.
*/
items() {
return this.belongsTo('Item', 'item_id');
},
});
export default bookshelf.model('ItemMetadata', ItemMetadata);
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',
},
},
};
}
}