Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. {
  2. ap_id: 23,
  3. name: "John",
  4. email: "John@domain.com",
  5. appointment_date: "23July,
  6. appointment_category: 3,
  7. time: "morning"
  8. },
  9.  
  10. var result = _.chain(allAppointments)
  11. .groupBy('date')
  12. .mapObject( date => _.groupBy(date, 'email' ) )
  13.  
  14. Response:
  15. {
  16. "23July": {
  17. "john@domain.com": [
  18. {
  19. "ap_id": 23,
  20. "name": "John",
  21. "email": "john@domain.com",
  22. "appointment_date": "23July",
  23. "appointment_category": 3,
  24. "time": "morning"
  25. },
  26. {
  27. "ap_id": 44,
  28. "name": "John",
  29. "email": "john@domain.com",
  30. "appointment_date": "23July",
  31. "appointment_category": 4,
  32. "time": "afternon"
  33. }
  34. ],
  35. "rose@domain.com": [
  36. {
  37. "ap_id": 55,
  38. "name": "Rose",
  39. "email": "rose@domain.com",
  40. "appointment_date": "23July",
  41. "appointment_category": 4,
  42. "time": "afternon"
  43. }
  44. ]
  45. },
  46. "29July": {
  47. "kate@domain.com": [
  48. {
  49. "ap_id": 70,
  50. "name": "Kate",
  51. "email": "kate@domain.com",
  52. "appointment_date": "29July",
  53. "appointment_category": 4,
  54. "time": "afternon"
  55. }
  56. ]
  57. }
  58. }
  59.  
  60. allAppointments_Filtered:
  61. [{
  62. ap_id: 23,
  63. name: "John",
  64. email: "John@domain.com",
  65. appointment_date: tomorrow,
  66. appointment_category: 3,
  67. time: "morning",
  68. hasMultipleAppointmentOnDate: "yes"
  69.  
  70. },{
  71.  
  72. "ap_id": 55,
  73. "name": "Rose",
  74. "email": "rose@domain.com",
  75. "appointment_date": "23July",
  76. "appointment_category": 4,
  77. "time": "afternoon"
  78. hasMultipleAppointmentOnDate: "nope"
  79.  
  80. },{
  81.  
  82. "ap_id": 44,
  83. "name": "John",
  84. "email": "john@domain.com",
  85. "appointment_date": "23July",
  86. "appointment_category": 4,
  87. "time": "afternoon"
  88. hasMultipleAppointmentOnDate: "yes"
  89.  
  90. },{
  91. ...
  92.  
  93. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement