Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Executing MongoDB Stored JavaScript/Procedures from Spring Java

I have few stored Javascripts in mongodb. I am using spring springframework.data.mongodb to access mongodb. How can i execute stored JavaScripts/procedures from this ?

like image 304
gsagrawal Avatar asked Oct 25 '12 16:10

gsagrawal


1 Answers

found the solution.

BasicDBObject obj = new BasicDBObject();
obj.append( "$eval" , "stored_javascript_name()" );

CommandResult t=mongoTemplate.executeCommand(obj);
Object obj1=t.get("retval");
like image 139
gsagrawal Avatar answered Sep 30 '22 18:09

gsagrawal