Meteor Collection 说它是空的

Meteor Collection Says It's Empty

我之前发布了这个 (),我不确定它是否已完全解决,但我相信出现了另一个问题。

在我的 client.js 文件中执行 console.log(Streams.find().fetch()); 时,结果是 []。但是当我使用 meteor mongo 检查数据库 (db.Streams.find().forEach(printjson)) 时,出现了三个不同的 objects。

怎么回事?

lib/streams.js中:

Streams = new Meteor.Collection("streams");

server/server.js中:

Meteor.publish("streams", function () {
  return Streams.find();
});

client/client.js中:

if(Meteor.isClient){
    Meteor.subscribe("streams");
    Template.body.helpers ({
      streams: function() {
        console.log(Streams.find().fetch());
        return Streams.find();
      }
   });
}

这是基于链接问题 () 的猜测。在那个问题中,您将集合称为 streams Streams = new Meteor.Collection("streams");

但是在这个问题中你使用的是Streams db.Streams.find().forEach(printjson) // Note the capital S in Streams

所以我想说这可能是区分大小写的事情,请尝试: Streams = new Mongo.Collection("Streams"); 这将正确匹配 mongo 集合的名称。同时将 Meteor.Collection 更改为更新的 Mongo.Collection