recipe.js 756 B

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