Mogodb java driver - raw command?

Is it possible to execute raw commands like javascript through the Java driver for MongoDB?

I'm tired of wrapping all Java objects with Rhino and happily sacrificing performance for the convenience of passing javascript directly to the database.

If not, I can always use sleepymongoose or something else, but for now I really don't want to add another language (python) to the stack.

Any ideas appreciated.

+4
source share
2 answers

not really. This command (String) can run any mango database commands, not arbitrary javascript. For the latter, you will need DB.eval (), which would lock your entire database if you are not using 1.7.2 mongo or later, and the noblock option is installed.

links: http://api.mongodb.org/java/2.4-rc0/index.html http://mongodb.onconfluence.com/display/DOCS/List+of+Database+Commands

+7
source

There are 2 DB.command () methods in the mongo java driver. One of 2 takes a string. I think this is what you are looking for.

Look here

0
source

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


All Articles