const mongoose = require('mongoose')

function image(img) {
  if (img) return '/uploads/images/lottery/' + img
}

const LotterySchema = mongoose.Schema({
  entryWidth: Number,
  entryHeight: Number,
  entryBgImg: { type: String, get: image },
  resultWidth: Number,
  resultHeight: Number,
  resultBgImg: { type: String, get: image },
  title: String,
  lotteryCode: String,
  participants: [],
  winnersCount: { type: Number, default: 1 },
  winnersList: [],
  expireDate: Number,
  expired: { type: Boolean, default: false }
})

module.exports = mongoose.model('Lottery', LotterySchema)
