merchant.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. squareLocation: String,
  31. inventory: [{
  32. ingredient: {
  33. type: mongoose.Schema.Types.ObjectId,
  34. ref: "Ingredient",
  35. required: true
  36. },
  37. quantity: {
  38. type: Number,
  39. required: true,
  40. min: 0
  41. },
  42. defaultUnit: {
  43. type: String,
  44. required: true
  45. }
  46. }],
  47. recipes: [{
  48. type: mongoose.Schema.Types.ObjectId,
  49. ref: "Recipe"
  50. }]
  51. });
  52. module.exports = mongoose.model("Merchant", MerchantSchema);