MongoDB find() returns a cursor

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Posts: 10
Joined: Sun Feb 09, 2014 5:55 am

MongoDB find() returns a cursor

Post by javmirval » Mon Mar 03, 2014 3:46 am

After strugling and finally understand with help from friends at Stackoverflow, how the find() command works in the interative javascript shell of MongoDB, now I know that find() returns a cursor.

db.test.find() -- This works in the shell because, internally it iterates in the cursor contents to show the documents.

Show the same documents when you:
var c = db.test.find()
while ( c.hasNext() ) printjson(

The thing now is how to code this in LC, I tried this in a mouseuo handler:
put shell("C:\mongodb\bin\mongo.exe --eval var c = db.test.find() ; while ( c.hasNext() ) printjson( )") into pJSON
put pJSON into fld "A" -- this step is only to "see"what is the result, pJSON, once all is worj=king will be passed to a function to make it an array.

but what i get in field "A" is:
MongoDB shell version: 2.2.7
connecting to: c
Sun Mar 02 01:12:52 SyntaxError: missing variable name (shell eval):1

Hope you can guide me!


Post Reply

Return to “Databases”