const mongoose = require('mongoose')
const paginate = require('mongoose-paginate-v2')

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

const WarrantySchema = mongoose.Schema({
  _creator: { type: mongoose.ObjectId, ref: 'User' },
  title: String,
  short_description: String,
  description: String,
  image: { type: String, get: image }
})
WarrantySchema.plugin(paginate)

module.exports = mongoose.model('Warranty', WarrantySchema)
