owner.js 991 B

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