I have a situation where I need to combine multiple update queries into single query:
db.collection.update([ when name = 'roshan' then set class = 1, when name = 'John' then set class=2 ])
In sql this can be done using update statement with case statement like:
update set class =(case when name = 'roshan' then 1 when name = 'John' then 2 end)
How could it be done in mongodb?
Note: update query in mongo provides only 1 update condition. I have different update condition and different update values as mentioned above.