'use strict'

const {TEXT} = require('sequelize')

module.exports = db => db.define('reviews', {
  body: {
    type: TEXT,
    validate: {
      len: {
        args: 30,
        msg: 'Review must be 30 characters in length'
      }
    }
  }
})

module.exports.associations = (Review, {Product, User}) => {
  Review.belongsToMany(Product, {through: 'ProductReviews'})
  Review.belongsToMany(User, {through: 'UserReviews'})
}

// or this can be in Product / User models where Product.hasMany(Review) and User.hasMany(Review)

@@ -322,20 +322,16 @@
 gsTo
-Many
 (Product
 , %7Bt
@@ -330,37 +330,8 @@
 duct
-, %7Bthrough: 'ProductReviews'%7D
 )%0A  
@@ -350,43 +350,13 @@
 gsTo
-Many
 (User
-, %7Bthrough: 'UserReviews'%7D
 )%0A%7D%0A

update associations