This repository has been archived on 2026-06-29. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
spellsaurus/api/models/spell-model.js
2021-01-01 22:07:22 +01:00

25 lines
653 B
JavaScript

'use strict'
const bookshelf = require('../database/bookshelf').bookshelf
require('./school-model')
require('./variable-model')
require('./ingredient-model')
let Spell = bookshelf.Model.extend({
tableName: 'spell',
hidden: [ 'author_id' ],
author() {
return this.belongsTo( 'User', 'author_id' );
},
schools() {
return this.belongsToMany( 'School', 'spell_school' );
},
variables() {
return this.belongsToMany( 'Variable', 'spell_variable' );
},
ingredients() {
return this.belongsToMany( 'Ingredient', 'spell_ingredient' );
}
})
module.exports = bookshelf.model('Spell', Spell)