如何使用" mysql case"在mongoDB中

时间:2017-02-01 05:49:33

标签: mongodb database

我想要查询此查询

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;

但是我无法在mongoDB查询中找到任何解决方案。我知道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})

有人可以帮助我吗?

0 个答案:

没有答案