recipe.js 710 B

12345678910111213141516171819202122232425262728
  1. const mongoose = require("mongoose");
  2. const RecipeSchema = new mongoose.Schema({
  3. posId: String,
  4. merchant: {
  5. type: mongoose.Schema.Types.ObjectId,
  6. ref: "Merchant",
  7. required: true
  8. },
  9. name: {
  10. type: String,
  11. required: true,
  12. },
  13. ingredients: [{
  14. ingredient: {
  15. type: mongoose.Schema.Types.ObjectId,
  16. ref: "Ingredient",
  17. required: [true, "Must provide ingredient"]
  18. },
  19. quantity: {
  20. type: Number,
  21. min: [0, "Cannot have a negative quantity"],
  22. required: [true, "Must provide a quantity"]
  23. }
  24. }]
  25. });
  26. module.exports = mongoose.model("Recipe", RecipeSchema);