How to execute shell request in Rockmongo or mongovue?

I ran the command in the mongo.exe file. Try the most basic command.

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

I got the results:

Now I will try a similar team in rockmongo. If I do

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

Result:

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

In principle, it seems to me that the result is in order or something like that? I'm not sure.

If I clarify:

 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 this:

 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 this mean that hello.tablebusiness → undefined is outside of me. As you see above, I only successfully execute a query in mongo.exe

It seems rockmongo has a very limited feature. I wonder how to actually see the result. How to execute an arbitrary mongodb command in rockmongo and observe the result.

+6
source share
2 answers

First of all, I agree with you: rockmongo has a very limited feature at the moment. I use it for simple queries because it allows me to access the remote server from any device that is turned on for viewing.

The rockmongo run area works with the Javascript API and does not behave like a mongo shell.

Try the following:

 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 by clicking on the collection name by entering a query condition in the upper pane ...

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

... and then "send request"

+8
source

An alternative answer, which may seem a little strange, is to use the aggregate method, but only the pipeline in one $match , for example:

 function () { return db.tablebusiness.aggregate([ { $match: { "_id": "the-simmons-paradise__41.85_-87.88" }} ]); } 
0
source

Source: https://habr.com/ru/post/923526/


All Articles