diff options
author | Mateja <mail@matejamaric.com> | 2021-07-20 21:41:54 +0200 |
---|---|---|
committer | Mateja <mail@matejamaric.com> | 2021-07-20 21:41:54 +0200 |
commit | ac59e730d434818d2daf1a6b83b5dc81b3a70518 (patch) | |
tree | c80baee08a75dd7717f83256bd2789af5bca133e /server/models | |
parent | 85a5d7851d9bbda9da8b84fb1872f952e637de23 (diff) | |
download | mevn-ecommerce-ac59e730d434818d2daf1a6b83b5dc81b3a70518.tar.gz mevn-ecommerce-ac59e730d434818d2daf1a6b83b5dc81b3a70518.zip |
Added Order model.
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/Order.js | 50 |
1 files changed, 50 insertions, 0 deletions
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; |