1

I want to perfrom this query

update abc
set color= case
WHEN indexValue=0.904 THEN 'rgba(0,0,0,0.3)'
WHEN indexValue=0.908 THEN 'rgba(0,0,0,0.3)'
WHEN indexValue=0.912 THEN 'rgba(255,255,255,0.3)'
WHEN indexValue >= 0.6 THEN 'rgba(0,80,0,0.6)'
WHEN indexValue >= -0.05 and indexValue<0 THEN 'rgba(128,128,128,0.6)'
END;

But I'm not able to find any solution for this in mongoDB query. I know this query of mongoDB:

db.abc.update( { $and: [ { indexValue: { $gte: 0.2 } }, { indexValue: { $lt:0.25 } } ] },
               {$set : {"color":"rgba(255,225,0,0.6)"}},
               {upsert:false, multi:true})

Can anybody help me out in this?

Community
  • 1
  • 1
gaurav singh
  • 1,376
  • 1
  • 15
  • 25
  • Possible duplicate of [Update multiple docs in a collection using switch case](http://stackoverflow.com/questions/41787787/update-multiple-docs-in-a-collection-using-switch-case) – felix Feb 01 '17 at 06:19
  • Possible duplicate of [Performing case-statement in mongodb aggregation framework](http://stackoverflow.com/questions/15494113/performing-case-statement-in-mongodb-aggregation-framework) – styvane Feb 01 '17 at 07:50

0 Answers0