const mongoose = require('mongoose')

function image(file) {
   return `/uploads/images/projects/${file}`
}

const ImagesSchema = mongoose.Schema({
   image: {type: String, get: image},
   created_at: String
}, {
   toObject: {getters: true},
   toJSON: {getters: true}
})


const ProjectSchema = mongoose.Schema({
   images: [ImagesSchema],
   project_details: {
      fa: {
         name: String,
         description: String
      },
      en: {
         name: String,
         description: String
      }
   },
   date: String,
   created_at: String,
   updated_at: String
})

module.exports = mongoose.model('Project', ProjectSchema)
