MongoDB(Java) - 如何运行javascript文件中保存的查询? [英] MongoDB (Java) - How to run query saved in javascript file?

查看:113
本文介绍了MongoDB(Java) - 如何运行javascript文件中保存的查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我之前有很多.js文件用于从命令行界面查询MongoDB,但现在我希望能够通过Java运行相同的查询(我使用Java来支持Web界面)依赖于查询中的信息)。如何使用来自Java驱动程序的JavaScript查询并返回一些我可以使用的数据(最终游戏是将结果格式化为HTML,如果有帮助的话)。

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

推荐答案

如果您需要在构建期间执行您的js文件,可以使用行家-mongodb的-插件。这个插件使用db.eval()...

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

这篇关于MongoDB(Java) - 如何运行javascript文件中保存的查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆