When does MongoDB Fetch results in java driver -
mongoclient mc=new mongoclient(); mongodatabase mdb=mc.getdatabase("testdb"); mongocollection mcol=mdb.getcollection("testcol"); finditerable<document> fi=mcol.find(); mongocursor<document> mcur=fi.iterator(); mongocursor<document> mcur2=fi.iterator();
will mcur , mcur2 have same results time reference of finditerable fi.
in step of above code mongodb results inside mongocursor or finditerable step?
mcol.find()
point results obtained, .find()
pull documents collection "testcol"
.
you don't need use finditerable
object ordinary list<basicdbobject>
work.
then can iterate through using:
for(dbobject obj : objlist) { //perform operations string name = (string) obj.get("nameoffield"); }
hope helps.
Comments
Post a Comment