Reputation: 994
How to select documents in a collection with a unique field in MongoDB?
I have this document schema:
{
_id: someid,
createdAt: new Date(),
message: somemessage,
eadd: eadd
}
I would like to get recent messages with unique email address. So the output will be recent messages per email address.
I don't know how to use Group by - can I use it here?
Upvotes: 0
Views: 52
Reputation: 17
You can try http://grapher.cultofcoders.com/ package. It will allow you to create relationships between your mongo collections. You will use links to create them and you can filter your requests to the database, pass parameters and more.
To install it
meteor add cultofcoders:grapher
Documentation can be found here: http://grapher.cultofcoders.com/
Upvotes: 0
Reputation: 2386
to get aggregation in Meteor, you'll have add a package. e.g. meteorhacks:aggregate
c.f. https://themeteorchef.com/tutorials/aggregations-in-mongodb
Upvotes: 1
Reputation: 1
You will have to use the mongo aggregate function
db.messages.aggregate(
[
{
$group : {
_id : "$eadd"}
}
]);
Just include the fields you want to show
Upvotes: 0