This is my code to get the data from a collection groupname which is initialised with the name of collection. I want to iterate the data stored in doc using foreach
loop.
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});
});
});
I've tried doing db.collectionname.find().forEach(....)
, but I've got an error saying that such function doesn't exists. Please help.