Reputation: 161
Using a java class i want to execute MongoDB shell query stored in a String variable.Currently i am using the following code.
String query="db.INSTANT.insert( { item: 'card', qty: 12 } )";
MongoClient mongo = new MongoClient("localhost",27017);
DB db = mongo.getDB("mydb");
db.eval(query);
The above code works fine for insert. But i want to execute find statement like query=db.INSTANT.find({"item":"card"})
.Is there any way to execute this query and print the collection set.
Upvotes: 1
Views: 2098