{
id:1, list:{
time:9:00AM,
branch:[cse,it],
count:30,
}, id:2, list:{
time:9:30AM,
branch:[cse,it],
count:20,
}
}
Der Code unten ist neuer Zweig anhängen auf Basis von id und Zeit in json DokumentServletException in mongodb Abfrage
public DBObject appendRoute(String id, String time, String groups,
int count) {
DBCollection coll = db.getCollection("groups");
BasicDBObject queryDocument = new BasicDBObject("id", id)
.append("list.time", time).append("list.count", count);
List<DBObject> sourceDocument = coll.find(queryDocument).toArray();
BasicDBObject elementToArray = new BasicDBObject("list.branch",
branch);
BasicDBObject pushElement = new BasicDBObject("$push", elementToArray);
coll.update(queryDocument, pushElement);
System.out.println(sourceDocument);
return sourceDocument.get(0);
}
Dieser Code unten Fehler wirft:
javax.servlet.ServletException: com.mongodb.WriteConcernException: {
"serverUsed" : "localhost/127.0.0.1:27017" , "connectionId" : 1 ,
"err" : "cannot use the part (list of list.count) to traverse the
element ({list: [ { time: \"9:00AM\", branches: [ ece ], count: \"20\"
}, { time: \"9:05AM\", branch: [ cse ], count: \"20\" }, "code" :
16837 , "n" : 0 , "ok" : 1.0}
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Bitte lassen Sie mich wissen, was ist das Problem in meinem Code?