最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

MongoDB (Java) - How to run query saved in javascript file? - Stack Overflow

programmeradmin1浏览0评论

So I have a lot of .js files that I have used to query MongoDB from the Command Line Interface before, but now I want to be able to run those same queries through Java (I am using Java to back a web interface that relies on the information from the query). How can I use those JavaScript queries from the Java driver and return some data that I can work with (the end game is to format the result into HTML, if that helps).

So I have a lot of .js files that I have used to query MongoDB from the Command Line Interface before, but now I want to be able to run those same queries through Java (I am using Java to back a web interface that relies on the information from the query). How can I use those JavaScript queries from the Java driver and return some data that I can work with (the end game is to format the result into HTML, if that helps).

Share Improve this question asked May 29, 2012 at 3:13 Sam SternSam Stern 25.1k13 gold badges97 silver badges129 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 2

If you need to executye your js files during buildtime, you can use maven-mongodb-plugin. This plugin uses db.eval()...

using Java IO to read your js files, filter the queries , execute the queries.

This not possible in an efficient way in current JAVA driver. Have a look here : mongodb java driver - raw mand?

发布评论

评论列表(0)

  1. 暂无评论