Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - support count unique #23

Open
rantav opened this issue Apr 7, 2015 · 3 comments
Open

Feature - support count unique #23

rantav opened this issue Apr 7, 2015 · 3 comments

Comments

@rantav
Copy link

rantav commented Apr 7, 2015

It would be nice and useful to support a count of uniques across a specified field in the collection documents (or to be able to provide a uniqueId function that accepts a document and returns its unique ID for the sake of this count).

Is this BTW perhaps already supported?...

Example:

Counts.publish(this, 'unique-name-of-counter', 
    Posts.find(), 
    {uniqueField: 'referrerId'});

// or: 

Counts.publish(this, 'unique-name-of-counter', 
    Posts.find(), 
    {uniqueFunction: function(post){
      return post.referrerId + '-' + post.userId;
    });
@tmeasday
Copy link
Member

tmeasday commented Apr 8, 2015

Hi @rantav - that seems like an interesting idea, although difficult to implement as we don't currently track any properties of our counted documents (except implicitly through the observer).

I think implementing such a feature would probably increase the complexity of the package quite a bit so I'm not sure it makes sense, given the package is pretty simple right now. If you wanted to put a PR together to do it, I'd happily take a look however.

@javaknight
Copy link

This is just an idea, but you may be able to achieve this using the newest version of Meteor and the rawConnection and rawCollection methods, which have access to distinct.

@rantav
Copy link
Author

rantav commented Apr 8, 2015

It can be done at first load, but how to keep it reactive, as new documents
are added? (Without having to keep a state on the node server)
On Apr 8, 2015 5:02 PM, "javaknight" [email protected] wrote:

This is just an idea, but you may be able to achieve this using the newest
version of Meteor and the rawConnection and rawCollection methods, which
have access to distinct.


Reply to this email directly or view it on GitHub
#23 (comment)
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants