front-end almost done | started back-end

This commit is contained in:
Amir Mohamadi
2020-11-23 19:39:26 +03:30
parent 95149f0e72
commit 80a7abafb7
191 changed files with 60163 additions and 950 deletions
+100
View File
@@ -0,0 +1,100 @@
const mongoose = require('mongoose')
function productImage(img) {
return '/uploads/images/products/' + img
}
function ProductImageGallery(img) {
return '/uploads/images/products/gallery/' + img
}
const ProductFeatureSchema = mongoose.Schema({
fa: {
name: String,
value: String
},
en: {
name: String,
value: String
},
de: {
name: String,
value: String
},
tr: {
name: String,
value: String
},
it: {
name: String,
value: String
},
created_at: String
})
const ProductImageSchema = mongoose.Schema({
image: {type: String, get: ProductImageGallery},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
const ProductSchema = mongoose.Schema({
image: {type: String, get: productImage},
stock: Number,
category: String,
product_details: {
fa: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
en: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
de: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
it: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
tr: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
}
},
product_features: [ProductFeatureSchema],
product_images: [ProductImageSchema],
created_at: String,
updated_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
module.exports = mongoose.model('Product', ProductSchema)