فهرست منبع

Add subingredients in the model.

Lee Morgan 5 سال پیش
والد
کامیت
c9232d28ac
1فایلهای تغییر یافته به همراه13 افزوده شده و 1 حذف شده
  1. 13 1
      models/ingredient.js

+ 13 - 1
models/ingredient.js

@@ -29,7 +29,19 @@ const IngredientSchema = new mongoose.Schema({
         type: Number,
         min: [0, "SIZE CANNOT BE A NEGATIVE NUMBER"],
         required: false
-    }
+    },
+    ingredients: [{
+        ingredient: {
+            type: mongoose.Schema.Types.ObjectId,
+            ref: "Ingredient",
+            required: true
+        },
+        quantity: {
+            type: Number,
+            required: true,
+            min: 0
+        }
+    }]
 });
 
 module.exports = mongoose.model("Ingredient", IngredientSchema);