G
G
giarmul2014-08-31 19:47:25
NoSQL
giarmul, 2014-08-31 19:47:25

Help with grouping and summing query in MongoDB?

There is a database structure of this type (statistics of sent and received e-mails):
{ from: "[email protected]", to: "[email protected]", date: new Date() }
{ from: "test @test.com", to: "[email protected]", date: new Date() }
{ from: "[email protected]", to: "[email protected]", date: new Date() }
how to make a request so that the output is in the form:
<e-mail> - <how much sent> - <how much received>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Vasiliev, 2014-08-31
@giarmul

Have you already looked here?
docs.mongodb.org/manual/core/aggregation-introduction

L
lega, 2014-09-01
@lega

You can make 2 simple requests: find({ from:"email" }).count() and find({ to:"email" }).count()
Better yet, store the incoming/outgoing counter in the "email/user profile" .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question