0
如何將此代碼轉換爲java?如何在java中使用聚合框架?任何人都可以請幫我...如何使用文檔和mongo聚合將mongo shell代碼轉換爲java代碼
我的Java代碼:
Document update = new Document("$project",new Document("TOTAL_EMPLOYEE_SALARY",new Document("$sum","$employees.EMP_SALARY")));
AggregationOutput output = coll.aggregate(update); // throwing some error in eclipse
我蒙戈shell代碼:
db.collection.aggregate([
{ "$project": {
"TOTAL_EMPLOYEE_SALARY": {
"$sum": "$employees.EMP_SALARY"
}
}}
])
您可以加入問題的錯誤? – Schore
其實eclipse不允許我寫這行:AggregationOutput output = coll.aggregate(update); 。它要求列表<'更新'。擴展BSON> – dev777