Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8048103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:19:24+00:00 2026-06-05T06:19:24+00:00

advertisers = db.dbname.find( ‘my query which returns things correctly’ ); I realize now that

  • 0
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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:19:26+00:00Added an answer on June 5, 2026 at 6:19 am

    The quick and dirty way is:

    var item;
    var items = db.test.find();
    while(items.hasNext()) {
       item = items.next();
       /* Do something with item */
    }
    

    There is also the more functional:

    items.forEach(function(item) {
       /* do something */
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script like this: use first_db; advertisers = db.agencies.find( 'my query which
Has anybody successfully integrated Clearcase with Teamcity (which advertises Clearcase support) to realize a
I am thinking about how to build advertise site which works like twitter. That
Currently, I'm trying to get a list of advertisers (See http://code.google.com/apis/gan/v1beta1/advertisers/list.html ) with my
I am going to develop a site that allow advertisers to post their products/services.
This is a sql query that I am using in a page that I
Why do some sites (or advertisers that give clients javascript code) employ a technique
So I setup a table using mysql query browser, and now i'm trying to
I'm completely noob with json. I need to parse a json that returns a
I have some data that looks like this: [ { _id : ObjectId(4e2f2af16f1e7e4c2000000a), advertisers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.