2020-12-21 02:16:42 +01:00
|
|
|
|
2022-09-11 11:45:33 +02:00
|
|
|
var mongoose = require('mongoose').set('debug', process.env.DEBUG)
|
2020-12-21 02:16:42 +01:00
|
|
|
|
|
|
|
|
var variantSchema = mongoose.Schema({
|
|
|
|
|
productID: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
imagePath: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
color: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
size: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
quantity: {
|
|
|
|
|
type: Number
|
|
|
|
|
},
|
|
|
|
|
title: {
|
|
|
|
|
type: String
|
|
|
|
|
},
|
|
|
|
|
price: {
|
|
|
|
|
type: Number
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var Variant = module.exports = mongoose.model('Variant', variantSchema);
|
|
|
|
|
|
|
|
|
|
module.exports.getVariantByID = function(id, callback){
|
|
|
|
|
Variant.findById(id, callback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports.getVariantProductByID = function(id, callback){
|
|
|
|
|
var query = {productID: id};
|
|
|
|
|
Variant.find(query, callback);
|
|
|
|
|
}
|
|
|
|
|
module.exports.getAllVariants = function(callback){
|
|
|
|
|
Variant.find(callback)
|
2021-09-22 01:13:41 +02:00
|
|
|
}
|