const mongoose = require('mongoose') const paginate = require('mongoose-paginate-v2') function cover(img) { if (img) return '/uploads/images/blog/' + img } function thumb(img) { return '/uploads/images/blog/thumb/' + img } function video(vi) { if (vi) return '/uploads/videos/blog/' + vi } const BlogPostSchema = mongoose.Schema({ locale: { fa: { title: String, description: String, short_description: String, last_section_image_title: String, last_section_image_description: String, last_section_title: String, last_section_description: String }, en: { title: String, description: String, short_description: String, last_section_image_title: String, last_section_image_description: String, last_section_title: String, last_section_description: String } }, cover: {type: String, get: cover}, thumb: {type: String, get: thumb}, video : {type: String, get: video}, last_section_image: {type: String, get: cover}, category: {type: mongoose.ObjectId, ref: 'BlogCategory'}, published: {type: Boolean, default: true} }) BlogPostSchema.plugin(paginate) module.exports = mongoose.model('BlogPost', BlogPostSchema)