recipe.js 633 B

1234567891011121314151617181920212223242526
  1. const mongoose = require("mongoose");
  2. const RecipeSchema = new mongoose.Schema({
  3. cloverId: {
  4. type: String,
  5. required: true
  6. },
  7. name: {
  8. type: String,
  9. required: true,
  10. minlength: [3, "Name of recipe must contain at least three characters"]
  11. },
  12. ingredients: [{
  13. id: {
  14. type: mongoose.Schema.Types.ObjectId,
  15. ref: "Ingredient"
  16. },
  17. quantity: {
  18. type: Number,
  19. min: [0, "Quantity cannot be a negative number"],
  20. required: true
  21. }
  22. }]
  23. });
  24. module.exports = mongoose.model("Recipe", RecipeSchema);