yudiao123 2016-05-18 01:54 采纳率: 0%
浏览 1995

java 调用Mongodb存储过程

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

  • 写回答

1条回答 默认 最新

  • oyljerry 2016-05-18 02:10
    关注

    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().

    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制