0
In dem folgenden Dokument wie bekomme ich das Feld filename
in Java?Suchen Sie ein einzelnes inneres Feld in MongoDB mit Java
> db.Audit.findOne({"auditorComments.filepath":"NewAudit6269242818132644222/withoutJS.txt"},{'auditorComments.$':1})
{
"_id" : ObjectId("573a02dbe4b017e93448707b"),
"auditorComments" : [
{
"username" : "[email protected]",
"date" : ISODate("2016-05-20T23:59:29.889Z"),
"filename" : "withoutJS.txt",
"filepath" : "NewAudit6269242818132644222/withoutJS.txt",
"comment" : "test",
"bugnumber" : "1234"
}
]
}
Ich habe einen Java-Code, aber es gibt immer null
public String getFilename(String key) {
DBCursor cur = audit.find(new BasicDBObject("auditorComments.filepath",key),new BasicDBObject ("auditorComments.$",1));
String test = null;
while (cur.hasNext()) {
test = (String) cur.next().get("auitorComments.filename");
System.out.print(test);
}
return null;
}