简体   繁体   中英

How many requests on server does Collection.find()?

I am a rookie in Meteor, so I hope I´am not asking something stupid.

My concern is: Will Meteor always do a request on the server when I´ll call the Collection.find() method? Or it fetch the data to the client by subscribing to them, and every find() get the data only from client?

I have a complex document and I need a couple helpers to render it. I want to use the advantage of Meteors reactive behavior, to render the changes that user makes to the document. I don´t want to pass the collection into session and reactive variables are not really an option because I´m using a couple subtemplates. Thanks :-)

No, find will not trigger communication with the server.

According to the Meteor documentation for new Mongo.Collection :

On the client (and on the server if you specify a connection), a Minimongo instance is created. Minimongo is essentially an in-memory, non-persistent implementation of Mongo in pure JavaScript. It serves as a local cache that stores just the subset of the database that this client is working with. Queries (find) on these collections are served directly out of this cache, without talking to the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM