Explorar o código

Create Transactions Schema

Lee Morgan %!s(int64=6) %!d(string=hai) anos
pai
achega
8d18362baf
Modificáronse 1 ficheiros con 28 adicións e 0 borrados
  1. 28 0
      models/purchase.js

+ 28 - 0
models/purchase.js

@@ -0,0 +1,28 @@
+const mongoose = require("mongoose");
+
+const PurchaseSchema = new mongoose.Schema({
+    merchant: {
+        type: mongoose.Schema.Types.ObjectId,
+        ref: "Merchant",
+        required: true
+    },
+    date: {
+        type: Date,
+        default: Date.now,
+        required: true
+    },
+    ingredients: [{
+        ingredient: {
+            type: mongoose.Schema.Types.ObjectId,
+            ref: "Ingredient",
+            required: true
+        },
+        quantity: {
+            type: Number,
+            required: true,
+            min: 0
+        }
+    }]
+});
+
+module.exports = mongoose.model("Purchase", PurchaseSchema);