Working with the result of subscriptions

Hi,

I have been wrestling with this for quite some time now… but I still am not sure how to tackle this.
I know you wait until subscriptions are ready. But does that mean that .find() will always and immediately return the document I am looking for? Can I query the local db, and assume all the documents I subscribed to are there? If I want to read a number from the db, and read another one, and multiply them, or whatever, can I assume both documents will be there if I ask for them?
Let’s assume I have a million documents in my db. If I subscribe to them, I will not recieve all (I hope!) But if I need two of them, and query for them, what happens?
These are not documents I want to display on my template, but rather “do something with” in JS, so putting them somewhere on the template and let the templateengine figure out when they are loaded will not suffice…

Any light on this is very welcome :slight_smile:

Paul

If you publish a million documents, you’ll actually have a million documents in your browser’s MiniMongo :wink:
Unless Meteor has a hard limit…

Ah! So that means that if the subscription is .ready() I will have all documents [I subscribed to] immediately available? A .find() will return the document, so I can loop through them and calculate with them?
(Obviously I will not be publishing a million documents, but that was just to get my question accross :slight_smile:)

Thank you for your answer; I had always be wondering about this. Best make my subscriptions nice and slim then! :sunglasses:

Paul

That’s generally a good policy :slight_smile: - but pub/sub is surprisingly complex and sometimes it’s better to over-subscribe to improve publication re-use.

Check out the Meteor Guide for a good introduction.