【发布时间】:2015-09-23 12:17:14
【问题描述】:
我有一个包含 170 万个文档的集合。在服务器端控制台上执行count() 时,我得到了正确的结果。
meteor:PRIMARY> db.postcodes.find().count();
1737697
meteor:PRIMARY>
而在浏览器控制台中,count() 总是为零,findOne() 返回 undefined。
insecure 包尚未删除。 count() 和 findOne() 正在为其他较小的 Collections 工作。目前没有太多代码。除了默认的html、js、css。只有几行代码存在。我有model.js 住在它自己的文件夹中(既不在服务器也不在客户端)有
PostCodes = new Mongo.Collection('postcodes');
Hello = new Mongo.Collection('hello');
我目前所有的收藏都是
meteor:PRIMARY> db.getCollectionNames();
[
"hello",
"meteor_accounts_loginServiceConfiguration",
"parttimejobs",
"postcodes",
"system.indexes",
"users"
]
meteor:PRIMARY>
我的包是
autopublish 1.0.3
ian:accounts-ui-bootstrap-3 1.2.69
insecure 1.0.3
meteor-platform 1.2.2
twbs:bootstrap 3.3.5
示例文档
meteor:PRIMARY> db.postcodes.findOne();
{
"_id" : ObjectId("559933dc4a8617644069fa5b"),
"postcode" : "AB10 1AB",
"latitude" : 57.149079,
"longitude" : -2.096964,
"county" : "",
"district" : "Aberdeen City",
"ward" : "George St/Harbour",
"constituency" : "Aberdeen North",
"loc" : [
-2.096964,
57.149079
]
}
【问题讨论】:
-
不看代码无从得知。
-
我已经用所有集合和 model.js 更新了我的问题
-
您是否删除了自动发布包??
-
我还没有创建频道。所以,自动发布仍然存在。
-
当客户端还没有收集时,您可能会要求计数,您必须在路由中创建一些 waitOn 函数等待收集准备好