1
私は従業員の文書を含むコレクションを持っています。各従業員は、この従業員が現在携わっているプロジェクトの文書配列を持っています。問題は、プロジェクトの配列を取得/照会する方法がわからないことです。JavaでmongoDBから文書の配列を取得する
このようなドキュメントの例を次に示します。
{name : "employe name" , age : "..employe age" , phoneNr : 12334 , projects :
[{ projectName : "project name" , projectLeder : "project leader" }] }
ここでは、ドキュメント内のプロジェクト配列以外の値を取得するためのコード例を示します。
public void printEmployees() {
MongoCursor<Document> cursor = coll.find().iterator();
while(cursor.hasNext()) {
Document documentEmployee = cursor.next();
System.out.println((String) documentEmployee.get("name"));
System.out.println((Integer) documentEmployee.get("age"));
System.out.println((Integer) documentEmployee.get("phoneNr"));
//How do i query/extract the project array?
}
}
ありがとうございました! – codeer