Guest User

Untitled

a guest
Nov 21st, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. {
  2.  
  3. "data": [
  4. {
  5. "_id": 366,
  6.  
  7. "logs": [
  8. {
  9. "id": 113,
  10. "booking_id": 366,
  11. "provider_id": 13,
  12. "cid": 11,
  13. "type": "basic",
  14. "time": 1542793756,
  15. },
  16. {
  17. "id": 116,
  18. "booking_id": 366,
  19. "provider_id": 13,
  20. "cid": 0,
  21. "type": "type2",
  22. },
  23.  
  24.  
  25. ],
  26. },
  27. {
  28. "_id": 362,
  29.  
  30. "logs": [
  31. {
  32. "id": 104,
  33. "booking_id": 362,
  34. "provider_id": 7,
  35. "cid": 10,
  36. "type": "basic",
  37. "time": 1542776677,
  38. }
  39. ],
  40. },
  41.  
  42. {
  43. "_id": 370,
  44.  
  45. "logs": [
  46. {
  47. "id": 111,
  48. "booking_id": 370,
  49. "provider_id": 9,
  50. "cid": 11,
  51. "type": "basic",
  52. "time": 1542792661,
  53. ]
  54. {
  55. "id": 112,
  56. "booking_id": 370,
  57. "provider_id": 11,
  58. "cid": 11,
  59. "type": "basic",
  60. "time": 1542793185,
  61. }
  62. ],
  63. "total_record": 2
  64. }
  65.  
  66. "total_record":3
  67.  
  68. query := []bson.M{
  69. {"$group": bson.M{
  70. "_id": "$booking_id",
  71. "logs": bson.M{ "$push": "$$ROOT" }
  72. "count": bson.M{"$sum":1},
  73. }},
  74. }
  75.  
  76. pipe := getCollection.Pipe(query)
  77. err = pipe.AllowDiskUse().One(&result)
Add Comment
Please, Sign In to add comment