On Sunday, 29 November 2015 22:24:02 UTC+11, Dragos wrote:
I am building a tool similar with RoboMongo in Java.
I am looking a way to execute text queries and map-reduce jobs using the Java driver.
Is the MongoDatabase#runCommand() the proper way ?
This works fine with a findOne() query which returns the result document, but find() doesn’t work or at least I don’t know how to get a cursor or similar.
Hi Dragos,
The runCommand() helper is used to run a database command on the server, which typically is at a much lower level than a text string provided by the end user.
The MongoDB Java driver has a MapReduceCommand class which helps construct a command for Map/Reduce. If you want to return a find() query as a cursor, you should use DBCollection#find().
If your goal is to transform user-provided text queries into BSON queries, you will need to parse the text rather than sending it directly to the server.
You might want to look into Jongo (http://jongo.org), which aims to provide a query interface in Java which is very similar to the mongo shell interface.
Regards,
Stephen
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c30da100-8457-48f9-bbb1-281412b38795%40googlegroups.com.
My target is to build a tool similar with RoboMongo in Java, plus other functionality.I understand I can use Jongo, but the language is still different. I want to let the server to complie and execute the code, is not my job to do this.If the C# driver can do this, I expect the Java driver can do this as well. RoboMongo is sending the text command to the server, I want to do the same from Java.