Updated role model and created perm model in API

This commit is contained in:
Alexis
2021-01-02 12:32:24 +01:00
parent 5cf2c1daa7
commit 16b7b81166
2 changed files with 19 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
const bookshelf = require('../database/bookshelf').bookshelf
require('./role-model')
let Permission = bookshelf.Model.extend({
tableName: 'permission',
hidden: [ 'id' ],
role() {
return this.belongsToMany( 'Role', 'role_permission' )
}
})
module.exports = bookshelf.model( 'Permission', Permission );

View File

@@ -1,7 +1,12 @@
const bookshelf = require('../database/bookshelf').bookshelf const bookshelf = require('../database/bookshelf').bookshelf
require('./permission-model')
let Role = bookshelf.Model.extend({ let Role = bookshelf.Model.extend({
tableName: 'role', tableName: 'role',
permissions() {
return this.belongsToMany( 'Permission', 'role_permission' );
}
}) })
module.exports = bookshelf.model('Role', Role); module.exports = bookshelf.model( 'Role', Role );