'use strict'

const {TEXT, FLOAT} = require('sequelize')

module.exports = db => db.define('reviews', {
  rating: {
    type: FLOAT,
    allowNull: false
  },
  comment: {
    type: TEXT,
    allowNull: true
  }
}, {
  getterMethods: {
    raterName: function() {
      this.getUser().then((user) => user.name)
    }
  }
})

module.exports.associations = (Review, {Magnet, User}) => {
  Review.belongsTo(User)
  Review.belongsTo(Magnet)
}

'use strict'

const {TEXT, FLOAT} = require('sequelize')

module.exports = db => db.define('reviews', {
  rating: {
    type: FLOAT,
    allowNull: false
  },
  comment: {
    type: TEXT,
    allowNull: true
  }
})

module.exports.associations = (Review, {Magnet, User}) => {
  Review.belongsTo(User)
  Review.belongsTo(Magnet)
}

remove unused getter