FullStack Assignment
FullStack Assignment
Q1. All Employee’s with the desg as ‘CLERK’ are now called as (AO)
Administrative Officers. Update the Employee collection for this.
Q2. Change the number of hours for project-1 to 5 for all employees
with designation analyst.
Sol. db.employees.updateMany({ "designation": "analyst" },{ $set: { "project-
1.hours": 5 } })
Q3. Add 2 projects project-3 and project-4 for employee whose name
starts with ”Deep” with 2 hrs
Sol. db.employees.updateMany({ name: { $regex: /^Deep/ } },{ $push: {
projects: { name: "project-3", hours: 2 } } },{ $push: { projects: { name:
"project-4", hours: 2 } } })
Q4. Add bonus rs 2000 for all employees with salary > 50000 and
1500 if salary <50000 and > 30000 otherwise bonus will be 1000
Q7. Decrease number of hrs by 2 for all employees who are working
on project-2
Sol. db.employee.updateMany({ project: "project-2" },{ $inc: { hrs: -2 } })
Q8. Delete project-2 from all employee document if they are working
on the project for 4 hrs.
Q9. Change the salary of employees to 10000 only if their salary is <
10000
Q15. Add list of skillset in all employee documents who are working
on project-4 for 3 hrs or on project-3 for 4 hrs
Q17. Increase salary by 10000 for all employees who are working on
project-2 or project-3 or project-1 Decrease bonus by 1000 rs And
increase salary by 1000rs for all employees whose department
location is Mumbai
Q20. Change skill python to python 3.8 for all employees if python is
there in the skillset
Sol. db.employees.updateMany({ skills: "python" },{ $set: { "skills.$": "python
3.8" } })
Q21. Add 2 skills MongoDb and Perl at the end of skillset array for all
employees who are working at Pune location
Sol. db.employees.updateMany({ location: "Pune" },{ $push: { skillset: {
$each: ["MongoDb", "Perl"] } } })
Q22. Delete first hobby from hobby array for all employees who are
working on project-1 or project-2
Q23. Delete last hobby from hobbies array for all employees who are
working on project which is at 2 nd position in projects array for 4
hrs
Q24. Add 2 new projects at the end of array for all employees whose
skillset contains Perl or python
Sol. db.employees.updateMany({ "skillset": { $in: ["Perl", "Python"] } },{
$push: { "projects": { $each: ["New Project 1", "New Project 2"] } } })
Q25. Change hrs to 6 for project-1 for all employees if they working
on the project-1 for < 6 hrs. otherwise keep the existing value.
Sol. db.employees.updateMany({ "project": "project-1", "hrs": { $lt: 6 } },{
$set: { "hrs": 6 } })