java 调用Mongodb存储过程

Mongodb3.0以后 db.eval() Deprecated since version 3.0.若是mongodb要写存储过程(js脚本),是不是有什么替代的执行方法。同时mongodb -java-driver3.0中DB类也已经置为Deprecated,其方法eval(),doEval()也一样,而MongoDataBase类中我没有找到执行脚本的方法,请问各位大神是不是有什么替代的方法,还是Mongodb不再建议执行js脚本,但我项目有执行类似存储过程的需求,可有解决方案?

You can create stored procedures on MongoDB in form of Javascript functions which are stored in the special collection db.system.js, but that's usually not advisable. Most of the reasons why stored procedures are useful for relational databases do not apply to MongoDB. Instead of calling a server-sided function from Java you should just implement said function directly in Java.

But when you still want to use them, creating such functions is documented as "storing functions server-sided". To execute them, you can use DB.command() or DB.doEval().