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

Provide .exists on cursors #46

Open
mitar opened this issue Dec 19, 2014 · 3 comments
Open

Provide .exists on cursors #46

mitar opened this issue Dec 19, 2014 · 3 comments

Comments

@mitar
Copy link

mitar commented Dec 19, 2014

One thing I am missing (from Django) is .exists() query, which would make an optimized query and tell you if the query matches any document. Doing .count() instead is very bad because you do not really need/want precise number (and counting a precise number is not very cheap in MongoDB).

Related: meteor/meteor#1504

@mitar
Copy link
Author

mitar commented Dec 19, 2014

It would be also good to have observeExists as a special case for when you just want to observe existence of a document in a reactive way.

Probably this could be just a wrapper around observeChanges with limit of fields only to _id. But maybe this could be made more efficiently.

@mquandalle
Copy link

This is where a database like RethinkDB is very good because basically it allow you to subscribe to any query. So for instance if you subscribe to a count() the database will only inform the subscriber when this number change and we don't have to subscribe to all matching document and count() them ourselves. It works for all reduce operations, as exists.

I understand that this suggestion is about minimongo but I just wanted to underline this feature of RethinkDB here. So about your suggestion itself, do we really need a observeExists in the observe callbacks list? Couldn't we simply rely on the .exists() reactivity (or maybe you think of the server)?

@mitar
Copy link
Author

mitar commented Dec 19, 2014

You are right. Much better than observeExists it would be if .count() would be reactive on the server as well. So yes, I am interested in publishing count() in a reactive way to the client in an efficient way. Or publishing things like .exists().

Maybe the question is more: we should have reactive queries on the server as well.

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

No branches or pull requests

2 participants