Q:

Update salary field value with 10 percent of each employee in employee collection in MongoDB

Please help me me out, i want to write a query in mongoDB which should be equivalent to the following MYSQL query.
Query - 
UPDATE emp SET salary = salary + (salary * 10)/100;

MongoDB emp Collection Format is like:
{
    "_id" : ObjectId("59ddce430d308e8d473ded8d"),
    "name" : "Ravi",
    "salary" : 6000
}
{
    "_id" : ObjectId("59ddce570d308e8d473ded8e"),
    "name" : "John",
    "salary" : 10000
}

I want to update both document with 10% increment in salary of each Employee.
Note- MongoDB Version is 3.2

A:

You can use $mul operator like this
db.emp.update({ "name": { $in: ["Ravi", "John"] } }, { $mul: { salary: 1.1 } });

