From ac59e730d434818d2daf1a6b83b5dc81b3a70518 Mon Sep 17 00:00:00 2001 From: Mateja Date: Tue, 20 Jul 2021 21:41:54 +0200 Subject: Added Order model. --- server/models/Order.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 server/models/Order.js (limited to 'server') diff --git a/server/models/Order.js b/server/models/Order.js new file mode 100644 index 0000000..9615373 --- /dev/null +++ b/server/models/Order.js @@ -0,0 +1,50 @@ +const mongoose = require('mongoose'); + +const OrderSchema = new mongoose.Schema({ + status: { + type: String, + required: true, + }, + paypalOrderId: { + type: String, + required: true + }, + userId: { + type: mongoose.Schema.Types.ObjectId, + required: false + }, + items: { + type: [{ + productId: { + type: mongoose.Schema.Types.ObjectId, + required: true + }, + quantity: { + type: Number, + required: true + } + }], + required: true + }, + shipping: { + name: { + full_name: String + }, + type: { + type: String + }, + address: { + address_line_1: String, + address_line_2: String, + admin_area_1: String, + admin_area_2: String, + postal_code: String, + country_code: String + }, + required: false + } +}); + +const OrderModel = new mongoose.model('Order', OrderSchema); + +module.exports = OrderModel; -- cgit v1.2.3