Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.92 KB | None | 0 0
  1. db.comment_object.aggregate([{
  2.         $match: {
  3.             $and: [{
  4.                 "beneficiaries": {
  5.                     $exists: true
  6.                 }
  7.             }, {
  8.                 "beneficiaries.0": {
  9.                     $exists: true
  10.                 }
  11.             }],
  12.             "last_payout": {
  13.                 "$gte": "2018-03-01T00:00:00",
  14.                 "$lt": "2018-06-09T00:00:00"
  15.             },
  16.             "total_payout_value": {
  17.                 "$gte": 0.001
  18.             }
  19.         }
  20.     },
  21.     {
  22.         $unwind: "$beneficiaries"
  23.     }, {
  24.         $group: {
  25.             _id: "$beneficiaries.account",
  26.  
  27.             author_gbg: {
  28.                 $sum: "$total_payout_value"
  29.             },
  30.             beneficiary_gbg: {
  31.                 $sum: "$beneficiary_payout_value"
  32.             },
  33.             curator_gbg: {
  34.                 $sum: "$curator_payout_value"
  35.             }
  36.         }
  37.     }
  38. ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement