merchant.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const mongoose = require("mongoose");
  2. const MerchantSchema = new mongoose.Schema({
  3. name: {
  4. type: String,
  5. required: true
  6. },
  7. email: String,
  8. password: {
  9. type: String,
  10. minlength: [15, "Password must contain at least 15 characters"]
  11. },
  12. pos: {
  13. type: String,
  14. required: true
  15. },
  16. posId: String,
  17. posAccessToken: String,
  18. lastUpdatedTime: {
  19. type: String,
  20. default: Date.now()
  21. },
  22. createdAt: {
  23. type: Date,
  24. default: Date.now
  25. },
  26. accountStatus: {
  27. status: String,
  28. expiration: Date,
  29. },
  30. inventory: [{
  31. ingredient: {
  32. type: mongoose.Schema.Types.ObjectId,
  33. ref: "Ingredient",
  34. required: true
  35. },
  36. quantity: {
  37. type: Number,
  38. required: true,
  39. min: [0, "Quantity cannot be less than 0"]
  40. }
  41. }],
  42. recipes: [{
  43. type: mongoose.Schema.Types.ObjectId,
  44. ref: "Recipe"
  45. }]
  46. });
  47. module.exports = mongoose.model("Merchant", MerchantSchema);