Full Stack Assignment 1
Full Stack Assignment 1
Section - D (71)
1. All Employee’s with the desg as ‘CLERK’ are now called as (AO)
Administrative Officers. Update the Employee collection for this.
2. Change the number of hours for project-1 to 5 for all employees with
designation analyst.
11. Add 2 new project at position 2 for all employees with designation
analyst or salary is equal to either 30000 or 33000 or 35000
12. Delete last project of all employees with department name is “HR”
and if the location is Mumbai
20. Change skill python to python 3.8 for all employees if python is
there in the skillset
21. Add 2 skills MongoDb and Perl at the end of skillset array for all
employees who are working at Pune location
22. Delete first hobby from hobby array for all employees who are
working on project-1 or project-2
23. 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
Ans
db.EmpDetail.updateMany({ project: { $size: 2 }, "Project-1.Hrs": 4 }, {
$pop: { hobbies: 1 } })
24. Add 2 new projects at the end of array for all employees whose
skillset contains Perl or python
Ans
db.employees.updateMany({ "skillset": { $in: ["Perl", "Python"] } },{ $push: {
"projects": { $each: ["New Project 1", "New Project 2"] } } })
25. 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.
Ans
db.EmpDetail.updateMany({ "project.name": "project-1",
"project.Hrs": { $lt: 6 } }, { $set: { "Hrs": 6 } })