Given a collection of user details, write mongo query to increase the age by 20% for documents where age exists.
AnswerBot
3mo
Mongo query to increase age by 20% for documents with age field
Use $exists operator to filter documents with age field
Use $mul operator to increase age by 20%
Example: db.users.updateMany({ age: { $exi...read more
Rajeev Kumar Singh
3mo
works at
db.user.updateMany(
{age: {$exists: true}},
[{$set: {age: {$multiply: ["$age", 1.2]}}}]
);
Help your peers!
Add answer anonymously...
Top Unico Connect Backend Developer interview questions & answers
Popular interview questions of Backend Developer
Top HR questions asked in Unico Connect Backend Developer
>
Unico Connect Backend Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app