【发布时间】:2016-09-08 16:50:10
【问题描述】:
这是我从以集合名称初始化的集合组名中获取数据的代码。我想使用foreach循环迭代存储在doc中的数据。
var db = mongojs('login');
var cursor = db.collection(groupname).find();
console.log(cursor);
cursor.each(function(err, doc) {
console.log(doc._id);
mongo.collection(doc._id + "group", function(err, collection) {
collection.remove({"groupname": groupname});
});
});
我尝试过db.collectionname.find().forEach(....),但我收到一个错误,提示该功能不存在。请帮忙。
【问题讨论】:
标签: node.js mongodb foreach mongojs