Use of Shell to get JSON from a MongoDB

Mark Wieder mwieder at ahsoftware.net
Thu Mar 6 01:29:22 EST 2014


Javier-

Wednesday, March 5, 2014, 8:19:14 AM, you wrote:

> 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.

> But still have some problems trying to get JSON from my local MongoDB.

You need to put quotes around the code to be evaluated if you're going
to try that from a command line. Try this (condensed into separate
lines to prevent email wraparound):

on mouseUp pMouseBtnNo
    local dbText
    
    put "var c=db.test.find();" into dbText
    put " while(c.hasNext())" after dbText
    put " printjson(c.next())" after dbText
    
    put shell("mongo --eval" && quote & dbText & quote) into field "A"
end mouseUp

-- 
-Mark Wieder
 ahsoftware at gmail.com

This communication may be unlawfully collected and stored by the National 
Security Agency (NSA) in secret. The parties to this email do not 
consent to the retrieving or storing of this communication and any 
related metadata, as well as printing, copying, re-transmitting, 
disseminating, or otherwise using it. If you believe you have received 
this communication in error, please delete it immediately.





More information about the use-livecode mailing list