mirror of
https://github.com/KevinMidboe/planetposen.git
synced 2025-12-28 21:01:10 +00:00
Server setup with mongodb.
Server handles creating and fetching products and their variations. Models are saved to mongo using mongoose. STILL PRETTY BARE BONES!
This commit is contained in:
15
server/schemas/Product.js
Normal file
15
server/schemas/Product.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const Product = new Schema({
|
||||
name: String,
|
||||
image: String,
|
||||
description: String,
|
||||
urlSlug: String,
|
||||
variations: [{
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "Variation"
|
||||
}]
|
||||
});
|
||||
|
||||
module.exports = mongoose.model("Product", Product)
|
||||
12
server/schemas/Variation.js
Normal file
12
server/schemas/Variation.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const Variation = new Schema({
|
||||
size: String,
|
||||
description: String,
|
||||
stock: Number,
|
||||
price: Number,
|
||||
discount: Number
|
||||
});
|
||||
|
||||
module.exports = mongoose.model("Variation", Variation);
|
||||
Reference in New Issue
Block a user