【问题标题】:Meteor Mongo: Collections not defined even after insertMeteor Mongo:即使在插入之后也没有定义集合
【发布时间】:2016-05-25 04:54:01
【问题描述】:

我在使用 Meteor 1.3 Beta.8 创建集合时遇到问题。我注意到使用代码时所有集合都未定义(我的工作文件夹根目录下的文件)

PlayersList = new Mongo.Collection('players');
if (Meteor.isClient) {
  //Some code
  Meteor.subscribe('players');
}
if (Meteor.isServer) {
  Meteor.startup(function () {

  /* Here some inserts */
  var players = [{name:'John', score: 5},{name:'AssFace', score: 10}];
  _.each(players, function(doc) {
    PlayersList.insert(doc);
  });

  Meteor.publish("players", function () {
    return PlayersList.find();
  });
}

于是我直接转向 Meteor Mongo 命令行工具,试了下,结果如下:

我在本地机器上遇到了完全相同的问题。 什么可能导致此问题?以及如何解决?谢谢。

【问题讨论】:

    标签: mongodb meteor


    【解决方案1】:

    我想你想要db.someCollection.find()

    【讨论】:

    • 我可能犯过的最愚蠢的错误。感谢您指出这一点。
    猜你喜欢
    • 1970-01-01
    • 2016-11-30
    • 1970-01-01
    • 1970-01-01
    • 2018-05-06
    • 2020-06-15
    • 1970-01-01
    • 1970-01-01
    • 2018-08-07
    相关资源
    最近更新 更多