Custom fields feature.

This commit is contained in:
Ahmed Bouhuolia
2019-09-13 20:24:09 +02:00
parent cba17739d6
commit ed4d37c8fb
64 changed files with 2307 additions and 121 deletions

38
server/src/models/View.js Normal file
View File

@@ -0,0 +1,38 @@
import bookshelf from './bookshelf';
const View = bookshelf.Model.extend({
/**
* Table name.
*/
tableName: 'views',
/**
* Timestamp columns.
*/
hasTimestamps: false,
/**
* View model belongs to resource model.
*/
resource() {
return this.belongsTo('Resource', 'resource_id');
},
/**
* View model may has many columns.
*/
columns() {
return this.belongsToMany('ResourceField', 'view_has_columns', 'view_id', 'field_id');
},
/**
* View model may has many view roles.
*/
viewRoles() {
return this.hasMany('ViewRole', 'view_id');
},
}, {
dependents: ['columns', 'viewRoles'],
});
export default bookshelf.model('View', View);