title: how exactly to use foreach in nodejs for Mongodb operations
body: <p>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 <code>foreach</code> loop.</p>
  
  <pre><code>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});
          });
      });
  </code></pre>
  
  <p>I've tried doing <code>db.collectionname.find().forEach(....)</code>, but I've got an error saying that such function doesn't exists. Please help.</p>