简体   繁体   English

Collection.find()在服务器上有多少个请求?

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

I am a rookie in Meteor, so I hope I´am not asking something stupid. 我是Meteor的新秀,所以希望我不要问愚蠢的事情。

My concern is: Will Meteor always do a request on the server when I´ll call the Collection.find() method? 我担心的是:当我调用Collection.find()方法时,Meteor会始终在服务器上发出请求吗? Or it fetch the data to the client by subscribing to them, and every find() get the data only from client? 还是通过订阅将数据获取到客户端,并且每个find()仅从客户端获取数据?

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. 我想利用Meteors反应行为的优点来呈现用户对文档所做的更改。 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. 否, find不会触发与服务器的通信。

According to the Meteor documentation for new Mongo.Collection : 根据有关new Mongo.Collection流星文档

On the client (and on the server if you specify a connection), a Minimongo instance is created. 在客户端(如果指定连接,则在服务器上)上,将创建一个Minimongo实例。 Minimongo is essentially an in-memory, non-persistent implementation of Mongo in pure JavaScript. Minimongo本质上是纯JavaScript中Mongo的内存非持久实现。 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. 这些集合中的查询(查找)直接从此缓存中提供,而无需与服务器通信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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