recipe.js 639 B

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