2015-09-07 118 views
0

我一直在使用MongoDB 3.0與Java一段時間,而且我從來沒有必須使用聚合,直到現在。 我現在需要這樣的功能,我想知道爲什麼MongoDB開發者沒有爲聚合添加任何靜態函數,就像他們對投影,過濾器和排序所做的那樣。MongoDB Java驅動程序3.0 - 用於彙總的靜態函數

例如,當你要查詢一個文檔,其中外地的docId等於1,則可以使用:

Document document = db.getCollection("test").find(new Document("$eq", new Document("docId", 1)).first(); 

或者,這是真棒(提供導入了model.Filters類) :

Document document = db.getCollection("test").find(eq("docID",1)).first(); 

但是,當涉及到聚集,你只有可用的第一個版本:

AggregateIterable<Document> iterable = db.getCollection("test").aggregate(asList(new Document("$match", new Document("docId", 1)))); 

是否有任何特殊的原因,他們沒有添加像匹配,組,排序,展開等靜態功能?或者,也許我在使用谷歌搜索這麼糟糕,我沒有找到它?

在此先感謝您的解釋!

回答