Creazione tabella Product

This commit is contained in:
Paolo Arena
2020-12-21 02:16:42 +01:00
parent 9ee59c0fc1
commit 67d2872e61
21 changed files with 767 additions and 42 deletions

View File

@@ -0,0 +1,40 @@
var mongoose = require('mongoose');
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)
}