使用远程mongodb和新流星1.3时遇到问题
var d = new MongoInternals.RemoteCollectionDriver("<mongo url>");
C = new Mongo.Collection("<collection name>", { _driver: d });
我把它放在我的集合文件夹中
if(Meteor.isServer){
var driver = new MongoInternals.RemoteCollectionDriver("mongodb://user:password@localhost:27017/customCollec");
}
C = new Mongo.Collection("customCollec", { _driver: driver });
但是在客户端这样的调用会让我回复: C
没有定义
console.log("" + C.find().count());
所以我在我的collections.js中测试了这样的同一行:
if(Meteor.isServer){
var driver = new MongoInternals.RemoteCollectionDriver("mongodb://user:password@localhost:27017/customCollec");
C = new Mongo.Collection("customCollec", { _driver: driver });
console.log("" + C.find().count());
}
但结果是一样的: C
未定义
另外我的设置是自动发布和不安全(dev staging)
提前感谢任何线索 .
1 回答
好吧,我终于想通了(流星1.3,自动发布)!
在lib / collections.js中
在此之后,我能够在客户端获得 Value
当然它只在加载集合时才有效 .
“希望它会有所帮助;)