recipe.js 571 B

12345678910111213141516171819202122232425
  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. required: true
  20. }
  21. }]
  22. });
  23. module.exports = mongoose.model("Recipe", RecipeSchema);