Guest User

Untitled

a guest
Sep 24th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. ## Users
  2. ```
  3. {
  4. username: {
  5. type: String,
  6. required: true,
  7. unique: true
  8. },
  9. password: {
  10. type: String,
  11. required: true,
  12. unique: true
  13. },
  14. email: {
  15. type: String,
  16. validate: [validateEmail,'Validation of `{PATH}` failed with value `{VALUE}`']
  17. }
  18. }
  19. ```
  20.  
  21. ### Email Validation function
  22. ```
  23. function validateEmail(email) {
  24. const re = new RegExp('[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}','i');
  25. if (!email) {
  26. return true;
  27. }
  28. return re.test(email);
  29. }
  30. ```
  31.  
  32. ## User Products
  33. ```
  34. {
  35. userId: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
  36. razors: [{
  37. productId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  38. comment: String
  39. nickname: String
  40. }],
  41. blades: [{
  42. productId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  43. comment: String
  44. nickname: String
  45. }],
  46. brushes: [{
  47. productId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  48. comment: String
  49. nickname: String
  50. }],
  51. lathers: [{
  52. productId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  53. comment: String
  54. nickname: String
  55. }],
  56. aftershaves: [{
  57. productId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  58. comment: String
  59. nickname: String
  60. }],
  61. additionalcares: [{
  62. productId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  63. comment: String
  64. nickname: String
  65. }]
  66. }
  67. ```
  68.  
  69. ## Shaves
  70. ```
  71. {
  72. userId: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
  73. razorId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  74. bladeId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  75. brushId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  76. latherId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  77. aftershaveId: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  78. additionalCare: { type: mongoose.Schema.Types.ObjectId, ref: "Product" },
  79. rating: Number,
  80. date: { type:Date, required:true }
  81. }
  82. ```
  83. ## Products
  84. ```
  85. {
  86. type: String,
  87. productType: { type: String, enum: ["razor", "blade", "brush", "lather", "aftershave", "additonalcare"]},
  88. brand: String,
  89. model: String,
  90. }
  91. ```
Add Comment
Please, Sign In to add comment