Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2017
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. [ { _id:
  2. { id: 59d0e3f728150e39b008013f,
  3. firstName: 'pera',
  4. lastName: 'pekko',
  5. phone: '04040404040',
  6. massageType: 'jipii massage',
  7. time: 45,
  8. price: 30,
  9. startsAt: '2017-10-02T11:00:00+03:00',
  10. endsAt: '2017-10-02T11:45:00+03:00' },
  11. email: [ 'gg@gmail.com' ],
  12. { _id:
  13. { id: 59ce25975f4d1a096cdd2733,
  14. firstName: 'sdad',
  15. lastName: 'autismus',
  16. phone: '04040404040',
  17. massageType: 'jipii massage',
  18. time: 60,
  19. price: 33,
  20. startsAt: '2017-10-02T12:45:00+03:00',
  21. endsAt: '2017-10-02T13:45:00+03:00' },
  22. email: [ 'YES@hotmail.com' ]
  23. }]
  24.  
  25. db3.massagerTimes.aggregate(
  26. {$match: {_id: mongo.helper.toObjectID(data.timesData)}},
  27. {$unwind: "$times"},
  28. {$match: {"times.type": 1}},
  29. {
  30. $group: {
  31. _id: {
  32. id: "$times._id",
  33. firstName: "$times.firstName",
  34. lastName: "$times.lastName",
  35. phone: "$times.phone",
  36. massageType: "$times.massageType",
  37. time: "$times.time",
  38. price: "$times.price",
  39. startsAt: "$times.startsAt",
  40. endsAt: "$times.endsAt"
  41. },
  42. email: {$addToSet: "$times.email"},
  43. count: {"$sum": 1}
  44. }
  45. },
  46. {
  47. $match: {
  48. count: {"$lte": 1}
  49. }
  50. },
  51. {$sort: {"times._id": -1}},
  52. function (err, result) {
  53. if (err)
  54. throw err;
  55.  
  56. if (result) {
  57. console.log(result);
  58. res.json(result);
  59. }
  60. });
  61. }
  62.  
  63. {
  64. "_id": {
  65. "$oid": "59ca4eb610b3be1f8499f6d5"
  66. },
  67. "times": [
  68. {
  69. "_id": {
  70. "$oid": "59ce274f5f4d1a096cdd2745"
  71. },
  72. "type": 0,
  73. "startsAt": "2017-10-02 13:30 +03:00",
  74. "endsAt": "2017-10-02 13:45 +03:00"
  75. },
  76. {
  77. "_id": {
  78. "$oid": "59ce274f5f4d1a096cdd2744"
  79. },
  80. "type": 0,
  81. "startsAt": "2017-10-02 13:15 +03:00",
  82. "endsAt": "2017-10-02 13:30 +03:00"
  83. },
  84. {
  85. "_id": {
  86. "$oid": "59ce28415f4d1a096cdd275b"
  87. },
  88. "title": "sdad autismus",
  89. "firstName": "sdad",
  90. "lastName": "autismus",
  91. "type": 1,
  92. "email": "YES@hotmail.com",
  93. "phone": "04040404040",
  94. "massageType": "jipii massage",
  95. "time": 45,
  96. "price": 30,
  97. "additionalInfo": null,
  98. "startsAt": "2017-10-01T08:30:00+03:00",
  99. "endsAt": "2017-10-01T09:15:00+03:00"
  100. },
  101. {
  102. "_id": {
  103. "$oid": "59ce28665f4d1a096cdd275e"
  104. },
  105. "title": "sdad autismus",
  106. "firstName": "sdad",
  107. "lastName": "autismus",
  108. "type": 1,
  109. "email": "YES@hotmail.com",
  110. "phone": "04040404040",
  111. "massageType": "jipii massage",
  112. "time": 45,
  113. "price": 30,
  114. "additionalInfo": null,
  115. "startsAt": "2017-10-01T09:30:00+03:00",
  116. "endsAt": "2017-10-01T10:15:00+03:00"
  117. },
  118. {
  119. "_id": {
  120. "$oid": "59d0e3f728150e39b008013f"
  121. },
  122. "title": "pera pekko",
  123. "firstName": "pera",
  124. "lastName": "pekko",
  125. "type": 1,
  126. "email": "gg@gmail.com",
  127. "phone": "04040404040",
  128. "massageType": "some massage",
  129. "time": 45,
  130. "price": 30,
  131. "additionalInfo": null,
  132. "startsAt": "2017-10-02T11:00:00+03:00",
  133. "endsAt": "2017-10-02T11:45:00+03:00"
  134. }
  135. ]
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement