开发者

mongodb java driver - raw command?

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

I'm tired of wrapping everything in Java objects using Rhino, and would happily sacrifice performance for the convenience of passing javascript directly through to the DB.

If not,开发者_C百科 I can always use sleepymongoose or something, but I don't really want to add yet another language (python) to the stack at this point.

Any insights are appreciated.


actually no. This command(String) can run any kind of mongo database commands, not arbitrary javascript. For the latter you would need DB.eval() which would block your whole DB unless you are using 1.7.2 mongo or later and the noblock option set.

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


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

See here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜