Reputation: 38771
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, 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.
Upvotes: 4
Views: 8433
Reputation: 114
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
Upvotes: 7