Use of Shell to get JSON from a MongoDB

Andrew Kluthe andrew at ctech.me
Wed Mar 5 13:12:38 EST 2014


I work with mongoDB a lot from livecode but unfortunately it is all through
REST API's built in other languages with native drivers so I can't help
here. :(


On Wed, Mar 5, 2014 at 10:19 AM, Javier Miranda V. <jemirandav at gmail.com>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.
>
> Issuing:
> db.test.find() -- This works in the shell because, internally it iterates
> in
> the cursor contents to show the documents.
>
> It show the same documents when you:
> var c = db.test.find()
> while ( c.hasNext() ) printjson( c.next())
>
> The thing now is how to code this in LiveCode, I tried this in a mouseup
> handler:
>
>
> put shell("C:\mongodb\bin\mongo.exe --eval var c = db.test.find() ; while (
> c.hasNext() ) printjson( c.next() )") 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!
>
> Javier
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
Regards,

Andrew Kluthe
andrew at ctech.me



More information about the use-livecode mailing list