recipe.js 767 B

1234567891011121314151617181920212223242526272829303132
  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. price: {
  14. type: Number,
  15. min: 0
  16. },
  17. ingredients: [{
  18. ingredient: {
  19. type: mongoose.Schema.Types.ObjectId,
  20. ref: "Ingredient",
  21. required: [true, "Must provide ingredient"]
  22. },
  23. quantity: {
  24. type: Number,
  25. min: [0, "Cannot have a negative quantity"],
  26. required: [true, "Must provide a quantity"]
  27. }
  28. }]
  29. });
  30. module.exports = mongoose.model("Recipe", RecipeSchema);