ingredient.js 697 B

1234567891011121314151617181920212223
  1. const mongoose = require("mongoose");
  2. const IngredientSchema = new mongoose.Schema({
  3. name: {
  4. type: String,
  5. minlength: [2, "Name of ingredient is two short. Please have at least two characters"],
  6. required: [true, "Must provide a name for the ingredient"]
  7. },
  8. category: {
  9. type: String,
  10. minlength: [3, "Category name must contain at least three characters"]
  11. },
  12. unitType: {
  13. type: String,
  14. require: [true, "You must provide the measurment unit for this item"]
  15. },
  16. recipes: [{
  17. type: mongoose.Schema.Types.ObjectId,
  18. ref: "Recipe"
  19. }]
  20. })
  21. module.exports = mongoose.model("Ingredient", IngredientSchema);