简体   繁体   English

如何检查Meteor.Collection是否同步?

[英]How do you check if a Meteor.Collection is synchronized?

In my application, I have an object whose fields are Meteor.Collections, some of which are not yet saved on the server. 在我的应用程序中,我有一个对象,其字段是Meteor.Collections,其中一些尚未保存在服务器上。 For example: 例如:

var tables = {};
tables["existent"] = new Meteor.Collection("existent"); // existent on server
tables["nonexistent"] = new Meteor.Collection(null); // nonexistent on server

I need to check if the collection also exists on the server. 我需要检查集合是否还存在于服务器上。 Is there any other way to check for that, other than attaching some flag to each Collection? 除了在每个Collection上附加一些标志之外,还有其他方法可以检查吗?

I discovered that Collections have a field, _name , where the name passed to the constructor is stored. 我发现Collections有一个字段_name ,其中存储了传递给构造_name的名称。 Therefore, if you check collection._name , it should return the name passed to it (if it was initialized with one), and null otherwise. 因此,如果您检查collection._name ,它应该返回传递给它的名称(如果它用一个初始化),否则返回null

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

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