【发布时间】:2020-03-26 19:47:12
【问题描述】:
我正在尝试为我的流星应用程序实现一个离线数据库,并选择使用 “GroundDB”。现在我仍处于早期学习阶段,但我遇到了一个我找不到解决方案的问题:
在我的离线收藏中使用 .find 时,我无法通过 id 找到。其他所有属性都有效。我的 mongo DB 中的一个典型对象如下所示:
{_id:"…someid", name:“test”, description:“test”, systemId:"…someID"};
我可以按名称、描述甚至 systemID 查找,但按 _id 查找总是返回 0 个结果。
什么可能导致这种行为?
这仅适用于 GroundDB。在 mongo 数据库中按 _id 查找有效。此外,GroundDB 中的“_id”字段也在那里!在没有过滤器的情况下执行.find({}) 时,我可以看到所有属性,包括 _id 字段,都被复制到了 groundb。
编辑
我目前关于 groundDB 的代码如下:
ExampleCol = new Mongo.Collection('exampleCol');
if (Meteor.isServer) {
Meteor.publish('exampleCol', functionexampleColPublication() {
return ExampleCol.find();
});
}
在客户端:
ExampleCol_GROUND = new Ground.Collection('exampleCol'
});
ExampleCol_GROUND.observeSource(ExampleCol.find());
然后:
ExampleCol_GROUND.find() 返回所有条目,它们也在 ExampleCol 中。我就是不能ExampleCol_GROUND.find({_id:"..."})(0 个结果)
【问题讨论】:
标签: mongodb meteor offline-caching findby grounddb