add calculation module and fix many bugs
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
function catalog(pdf) {
|
||||
return '/uploads/pdf/' + pdf
|
||||
if (pdf) return '/uploads/pdf/' + pdf
|
||||
}
|
||||
|
||||
const MainCatalogSchema = mongoose.Schema({
|
||||
file: {type: String, get: catalog},
|
||||
created_at: String
|
||||
file: {
|
||||
fa: {type: String, get: catalog},
|
||||
en: {type: String, get: catalog}
|
||||
},
|
||||
created_at: String,
|
||||
updated_at: String
|
||||
}, {
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
})
|
||||
|
||||
module.exports = mongoose.model('MainCatalog', MainCatalogSchema)
|
||||
|
||||
@@ -1,84 +1,89 @@
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
function productImage(img) {
|
||||
return '/uploads/images/products/' + img
|
||||
if (img) return '/uploads/images/products/' + img
|
||||
}
|
||||
|
||||
function productPDF(file) {
|
||||
return '/uploads/pdf/' + file
|
||||
if (file) return '/uploads/pdf/' + file
|
||||
}
|
||||
|
||||
const ProductImageSchema = mongoose.Schema({
|
||||
image: {type: String, get: productImage},
|
||||
created_at: String
|
||||
image: {type: String, get: productImage},
|
||||
created_at: String
|
||||
}, {
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
})
|
||||
|
||||
const ProductPDFSchema = mongoose.Schema({
|
||||
file: {type: String, get: productPDF},
|
||||
pdf_details: {
|
||||
fa: {
|
||||
name: String
|
||||
},
|
||||
en: {
|
||||
name: String
|
||||
}
|
||||
},
|
||||
created_at: String
|
||||
file: {
|
||||
fa: {type: String, get: productPDF},
|
||||
en: {type: String, get: productPDF}
|
||||
},
|
||||
pdf_details: {
|
||||
fa: {
|
||||
name: String
|
||||
},
|
||||
en: {
|
||||
name: String
|
||||
}
|
||||
},
|
||||
created_at: String
|
||||
}, {
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
})
|
||||
|
||||
const ProductSchema = mongoose.Schema({
|
||||
cover: {type: String, get: productImage},
|
||||
images: [ProductImageSchema],
|
||||
more_section_image1: {type: String, get: productImage},
|
||||
more_section_image2: {type: String, get: productImage},
|
||||
render_image1: {type: String, get: productImage},
|
||||
render_image2: {type: String, get: productImage},
|
||||
chart_image: {type: String, get: productImage},
|
||||
pdf_files: [ProductPDFSchema],
|
||||
category: String,
|
||||
more_section: {type: Boolean, default: true},
|
||||
download_section: {type: Boolean, default: true},
|
||||
product_details: {
|
||||
fa: {
|
||||
name: String,
|
||||
short_description: String,
|
||||
page_title: String,
|
||||
page_description: String,
|
||||
more_title1: String,
|
||||
more_description1: String,
|
||||
more_title2: String,
|
||||
more_description2: String,
|
||||
render_caption1: String,
|
||||
render_caption2: String,
|
||||
chart_title: String,
|
||||
chart_description: String
|
||||
},
|
||||
en: {
|
||||
name: String,
|
||||
short_description: String,
|
||||
page_title: String,
|
||||
page_description: String,
|
||||
more_title1: String,
|
||||
more_description1: String,
|
||||
more_title2: String,
|
||||
more_description2: String,
|
||||
render_caption1: String,
|
||||
render_caption2: String,
|
||||
chart_title: String,
|
||||
chart_description: String
|
||||
}
|
||||
},
|
||||
created_at: String,
|
||||
updated_at: String
|
||||
cover: {type: String, get: productImage},
|
||||
thumb: {type: String, get: productImage},
|
||||
images: [ProductImageSchema],
|
||||
more_section_image1: {type: String, get: productImage},
|
||||
more_section_image2: {type: String, get: productImage},
|
||||
render_image1: {type: String, get: productImage},
|
||||
render_image2: {type: String, get: productImage},
|
||||
chart_image: {type: String, get: productImage},
|
||||
pdf_files: [ProductPDFSchema],
|
||||
category: String,
|
||||
more_section: {type: Boolean, default: true},
|
||||
download_section: {type: Boolean, default: true},
|
||||
favorite: {type: Boolean, default: false},
|
||||
product_details: {
|
||||
fa: {
|
||||
name: String,
|
||||
short_description: String,
|
||||
page_title: String,
|
||||
page_description: String,
|
||||
more_title1: String,
|
||||
more_description1: String,
|
||||
more_title2: String,
|
||||
more_description2: String,
|
||||
render_caption1: String,
|
||||
render_caption2: String,
|
||||
chart_title: String,
|
||||
chart_description: String
|
||||
},
|
||||
en: {
|
||||
name: String,
|
||||
short_description: String,
|
||||
page_title: String,
|
||||
page_description: String,
|
||||
more_title1: String,
|
||||
more_description1: String,
|
||||
more_title2: String,
|
||||
more_description2: String,
|
||||
render_caption1: String,
|
||||
render_caption2: String,
|
||||
chart_title: String,
|
||||
chart_description: String
|
||||
}
|
||||
},
|
||||
created_at: String,
|
||||
updated_at: String
|
||||
}, {
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user