Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute shell some query in Rockmongo or mongovue?

Tags:

mongodb

I executed a command in mongo.exe. Let's try with the most basic command.

> db.tablebusiness.find({"_id": "the-simmons-paradise__41.85_-87.88"});

I got results:

Now I try similar command in rockmongo. If I execute

db.tablebusiness.find(
    {"_id": "the-simmons-paradise__41.85_-87.88"}
    );

Result:

{
   "retval": null,
   "ok": 1
} 

Basically it seems to tell me that the result is ok or something like that? I am not sure.

If I elaborate:

var cur = db.tablebusiness.find(
{"_id": "the-simmons-paradise__41.85_-87.88"}
);
cur.forEach(function(x){print(tojson(x))});

Result:

{
   "retval": null,
   "ok": 1
} 

Same problem.

If I do:

function () {
   return db.tablebusiness.find({"_id": "the-simmons-paradise__41.85_-87.88"});
}

I got:

 {
   "retval": {
     "value": "DBQuery: hello.tablebusiness -> undefined"
  },
   "ok": 1
}   

What does it mean by hello.tablebusiness -> undefined is beyond me. As you see from above, I successfully execute the query just fine in mongo.exe

Looks like rockmongo has very limited feature. I wonder how to actually see result. How to execute random mongodb command in rockmongo and observe the result.

like image 932
user4951 Avatar asked Aug 23 '12 02:08

user4951


1 Answers

First of all I agree with you: rockmongo has very limited feature at the moment. I use it for simple queries because allows me access to my remote server from any browsing enabled device.

The "execute" area in rockmongo run with "Javascript API" and not behave like the mongo shell.

Try this:

function () {
    var cur = db.tablebusiness.find(
    {"_id": "the-simmons-paradise__41.85_-87.88"}
    );
    var out = [];
    cur.forEach(function(x){out.push(x);});
    return(out);
}

You can run simple queries clicking on the collection name, typing your query condition in the upper area...

 {"_id": "the-simmons-paradise__41.85_-87.88"}

...and then "submit query"

like image 174
baffonero Avatar answered Nov 12 '22 02:11

baffonero