const mongoose = require('mongoose')
const timestamp = require('mongoose-timestamp')

const advertisingRatingSchema = new mongoose.Schema({
  advertisingId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'Advertising',
    required: true
  },
  userId: {
    type: mongoose.Schema.Types.ObjectId,
    ref: 'User',
    required: true
  },
  rating: {
    type: Number,
    required: true,
    min: 1,
    max: 5
  }
})

advertisingRatingSchema.plugin(timestamp)

const AdvertisingRatingModel = mongoose.model('AdvertisingRating', advertisingRatingSchema)
module.exports = AdvertisingRatingModel
