merchant.js 730 B

123456789101112131415161718192021222324252627282930313233
  1. const mongoose = require("mongoose");
  2. const MerchantSchema = new mongoose.Schema({
  3. name: {
  4. type: String,
  5. required: true
  6. },
  7. cloverId: {
  8. type: String,
  9. required: true
  10. },
  11. lastUpdatedTime: {
  12. type: String,
  13. default: Date.now()
  14. },
  15. inventory: [{
  16. ingredient: {
  17. type: mongoose.Schema.Types.ObjectId,
  18. ref: "Ingredient"
  19. },
  20. quantity: {
  21. type: Number,
  22. min: [0, "Quantity cannot be less than 0"],
  23. required: true
  24. }
  25. }],
  26. recipes: [{
  27. type: mongoose.Schema.Types.ObjectId,
  28. ref: "Recipe"
  29. }]
  30. });
  31. module.exports = mongoose.model("Merchant", MerchantSchema);