front-end almost done | started back-end
This commit is contained in:
@@ -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)
|
||||
@@ -0,0 +1,39 @@
|
||||
const mongoose = require('mongoose')
|
||||
|
||||
function image(img) {
|
||||
return '/uploads/images/products/category/' + img
|
||||
}
|
||||
|
||||
const ProductCategorySchema = mongoose.Schema({
|
||||
image: {type: String, get: image},
|
||||
cover: {type: String, get: image},
|
||||
category_details: {
|
||||
fa: {
|
||||
name: String,
|
||||
caption: String
|
||||
},
|
||||
en: {
|
||||
name: String,
|
||||
caption: String
|
||||
},
|
||||
de: {
|
||||
name: String,
|
||||
caption: String
|
||||
},
|
||||
tr: {
|
||||
name: String,
|
||||
caption: String
|
||||
},
|
||||
it: {
|
||||
name: String,
|
||||
caption: String
|
||||
}
|
||||
},
|
||||
created_at: String,
|
||||
updated_at: String
|
||||
}, {
|
||||
toObject: {getters: true},
|
||||
toJSON: {getters: true}
|
||||
})
|
||||
|
||||
module.exports = mongoose.model('ProductCategory', ProductCategorySchema)
|
||||
Reference in New Issue
Block a user