Creating a filter in mongoDB

0

Well, I need some help on creating a filter in Mongo DB to better organize my results. Today my database is set up like this:

{ "_id" : 2, "email": "[email protected]", "conversao": 5}
{ "_id" : 3, "email": "[email protected]", "conversao": 10}
{ "_id" : 4, "email": "[email protected]", "conversao": 10}
{ "_id" : 5, "email": "[email protected]", "conversao": 25}
{ "_id" : 5, "email": "[email protected]", "conversao": 2}

I need to create a group where I can group the emails, not to repeat themselves again, and get the value of the last conversion made.

An example of how to stay:

{ "email": "[email protected]", "conversao": 10}
{ "email": "[email protected]", "conversao": 25}
{ "email": "[email protected]", "conversao": 2}

Can anyone help me? I'm new to mongo so I do not know how to do this or even pass a sample code to you. I know I should use Mongo's $ group.

Note: If someone has a better idea to organize the emails by group I also accept.

Thank you very much

    
asked by anonymous 05.12.2018 / 14:44

0 answers