这个Meteor客户端代码应该将一个集合中的所有文档插入到另一个集合中,但是ToCollection.find({}).count()返回0。知道怎么解决这个问题吗?
//client/lib.js
toCollection = new Mongo.Collection('null');
Meteor.subscribe('fromCollection'); //<------FromCollection has many documents
FromCollection.find({}).forEach((doc) => {
toCollection.insert(doc); //<------but nothing was inserted
});发布于 2016-06-25 02:40:54
您需要正确地创建集合,比如
var toCollection = new Mongo.Collection('toCollection');
var fromCollection = new Mongo.Collection('fromCollection');通知
new Mongo.Collection的单个参数是集合的名称,而不是值'null‘的字符串。https://stackoverflow.com/questions/38012525
复制相似问题