owner.js 938 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const mongoose = require("mongoose");
  2. let emailValid = require("../validator.js").emailValid;
  3. const OwnerSchema = new mongoose.Schema({
  4. email: {
  5. type: String,
  6. required: [true, "EMAIL IS REQUIRED"],
  7. validate: {
  8. validator: emailValid,
  9. message: "INVALID EMAIL ADDRESS"
  10. },
  11. index: true
  12. },
  13. name: String,
  14. password: {
  15. type: String,
  16. required: true
  17. },
  18. square: {
  19. id: String,
  20. accessToken: String,
  21. expires: Date,
  22. refreshToken: String,
  23. },
  24. createdAt: {
  25. type: Date,
  26. default: new Date()
  27. },
  28. status: [],
  29. session: {
  30. sessionId: {
  31. type: String,
  32. index: true
  33. },
  34. expiration: Date
  35. },
  36. merchants: [{
  37. type: mongoose.Schema.Types.ObjectId,
  38. ref: "Merchant"
  39. }]
  40. });
  41. module.exports = mongoose.model("Owner", OwnerSchema);