merchant.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  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
  40. },
  41. displayUnit: {
  42. type: String,
  43. required: true
  44. }
  45. }],
  46. recipes: [{
  47. type: mongoose.Schema.Types.ObjectId,
  48. ref: "Recipe"
  49. }]
  50. });
  51. module.exports = mongoose.model("Merchant", MerchantSchema);