Updated models to include roles

This commit is contained in:
Alexis
2020-12-30 21:52:06 +01:00
parent 0fd0253fb4
commit 3bdf43d11b
2 changed files with 14 additions and 2 deletions

7
api/models/role-model.js Normal file
View File

@@ -0,0 +1,7 @@
const bookshelf = require('../database/bookshelf').bookshelf
let Role = bookshelf.Model.extend({
tableName: 'role',
})
module.exports = bookshelf.model('Role', Role);

View File

@@ -1,9 +1,14 @@
'use strict'
const bookshelf = require('../database/bookshelf').bookshelf
const bookshelf = require('../database/bookshelf').bookshelf;
require('./role-model');
let User = bookshelf.Model.extend({
tableName: 'user',
hidden: ['id', 'password']
hidden: [ 'password' ],
role() {
return this.belongsTo( 'Role' );
},
})
module.exports = bookshelf.model('User', User)