Advertisement
Guest User

Untitled

a guest
Aug 4th, 2017
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. {
  2. "_id" : ObjectId("59816ac004ca1760a45957d0"),
  3. "userEmail" : "lk@gmail.com",
  4. "expenseAmount" : 500,
  5. "expenseRemark" : "raj",
  6. "expenseCategory" : "transport",
  7. "transactionType":"debit",
  8. "entryTime" : ISODate("2017-08-02T06:01:26Z"),
  9. "__v" : 0
  10. },
  11. {
  12. "_id" : ObjectId("59816acb04ca1760a45957d1"),
  13. "userEmail" : "lk@gmail.com",
  14. "expenseAmount" : 100,
  15. "expenseRemark" : "pet",
  16. "expenseCategory" : "pets",
  17. "transactionType":"debit",
  18. "entryTime" : ISODate("2017-08-02T06:01:37Z"),
  19. "__v" : 0
  20. },
  21. {
  22. "_id" : ObjectId("597d7a9c04ca1760a45957d2"),
  23. "userEmail" : "lk@gmail.com",
  24. "expenseAmount" : 500,
  25. "expenseRemark" : "gt",
  26. "expenseCategory" : "sports",
  27. "transactionType":"debit",
  28. "entryTime" : ISODate("2017-07-30T06:20:04Z"),
  29. "__v" : 0
  30. },
  31. {
  32. "_id" : ObjectId("597d7aaa04ca1760a45957d3"),
  33. "userEmail" : "lk@gmail.com",
  34. "expenseAmount" : 560,
  35. "expenseRemark" : "mov",
  36. "expenseCategory" : "entertainment",
  37. "transactionType":"debit",
  38. "entryTime" : ISODate("2017-07-30T06:20:14Z"),
  39. "__v" : 0
  40. }
  41.  
  42. db.expenses.aggregate(
  43. [
  44. {
  45. $match:{"userEmail":"lk@gmail.com","entryTime":{"$month": 7}}
  46. },
  47. {$group:{ _id : null, total : {$sum : "$expenseAmount"}}}
  48. ]
  49. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement