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