updating multiple records in mongodb using java by filtering and iterating through each record -


i trying update document field code , selects document have common field value trying update document value unique each document

what have done :

     (map.entry<string, float> entry : maps.entryset())     {         system.out.println(entry.getkey() + " : " + entry.getvalue());         finditerable<document> iterable1 = doccollection.find(filters.eq("product_currency", entry.getkey()));         iterator<document> iter1=iterable1.iterator();         while(iter1.hasnext())         {             /*              * replace previous entry              */             document theobj = iter1.next();              double retailprice = (theobj.getdouble("product_price_retail"))/entry.getvalue();               document doc =new document("product_price_usd",retailprice);               doccollection.updatemany(filters.eq("product_currency",               entry.getkey()), new document("$set",doc));             system.out.println("doc updated!");             count++;          }      } 

here map contains currency rates follow:

hrk : 6.8751 mxn : 18.4137 lvl : 0.6205 ltl : 3.0487 zar : 15.9894 inr : 67.825 cny : 6.5675 thb : 35.52 aud : 1.4099 ils : 3.8809 krw : 1209.145 jpy : 117.415 pln : 3.9583 gbp : 0.6887 

but when update runs document have same field value. failed find issue why happening please suggest me solution.

thanks in advance


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -