Creazione tabella Product
This commit is contained in:
40
src/server/models/variant.js
Normal file
40
src/server/models/variant.js
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user