問題描述
如何從 java 程序運行 mongo 查詢? (How to run a mongo query from java program?)
我們從 mongo‑shell 運行的查詢,我想從 java 程序運行相同的查詢。我該怎麼做?
參考解法
方法 1:
I believe what you are looking for is mentioned in the comment in the answer to Create a Mongo query in Java using a String in that the library Jongo is what you are looking for. See http://jongo.org/ . Looks like not 100% the same e.g. db.collection.find(QUERY) becomes friends.find(QUERY) where query is a string. But it is closer than making the entire query into a DBObject.
(by Sumit Bharati、Cervo)