0
我需要有以下查詢轉換到Java代碼查詢具體的MongoDB領域
使用DBNAME
db.collectionName.find({},{參考:1})
我想爲關鍵的「參考」
獲取值我試過但這似乎以下不按照要求進行調整
Mongo dbConnection;
DB dbobject;
dbConnection = new Mongo("localhost", 27017);
dbobject = dbConnection.getDB("dbName");
DBCollection profileCollection = dbobject.getCollection("collectionName");
BasicDBObject query = new BasicDBObject();
query.put("{},{reference:1}");
DBCursor mongocursor =profileCollection.find("{}, {reference:1}");
try {
while(mongocursor.hasNext()) {
System.out.println(mongocursor.next().get("reference"));
}
} finally {
mongocursor.close();
}