advertisers = db.dbname.find( 'my query which returns things correctly' );
I realize now that it returns a cursor to the list of collections.
But I am not sure how to loop through them and get each collection.
I want to try something like this:
advertisers.each(function(err, advertiser) {
console.log(advertiser);
});
But that does not work. But I didn’t see from searching online how to make it actually work with simple JavaScript.
Then I have this code:
var item;
if ( advertisers != null )
{
while(advertisers.hasNext())
{
item = advertisers.next();
}
}
and it gives this error: SyntaxError: syntax error (shell):1
Help much appreciated!
Thanks!
The quick and dirty way is:
There is also the more functional: