Lab Version

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

db.

createCollection("employees")

db.employees.insertMany([
{_id: 1, "Name": "Steve Badiola", "Salary": 16099.55, "Position": "President",
"Rank": 1, "ReportingTo": null},
{_id: 2, "Name": "Jamir Garcia", "Salary": 14567.12, "Position": "Vice-President",
"Rank": 2, "ReportingTo": ["President"]},
{_id: 3, "Name": "Reg Rubio", "Salary": 13891.22, "Position": "Secretary", "Rank":
3, "ReportingTo": ["Vice-President"]},
{_id: 4, "Name": "Ian Tayao", "Salary": 13000, "Position": "Treasurer", "Rank": 4,
"ReportingTo": ["Secretary", "Vice-President"]}])

db.employees.updateMany({"ReportingTo": null}, {"$unset": {"ReportingTo": 1}})

db.employees.updateMany({}, {"$inc": {"Salary": 5000}})

db.employees.updateOne({"Name": "Reg Rubio"}, {$set: {"ReportingTo": ["President",


"Vice-President"]}})

db.employees.updateOne({"Name": "Ian Tayao"}, {$set: {"ReportingTo": ["President",


"Vice-President", "Secretary"]}})

db.employees.find({"Salary": {$gt: 21000}}).pretty()

db.employees.find({$or: [{"Name": /^R/}, {"Name": /^S/}]})

You might also like