You are on page 1of 8

use MongoLab1

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.deleteOne(

{ReportingTo: null}

)
db.employees.updateOne(

{Name: “Reg Rubio”},

{$set:{ReportingTo:[‘President’]}}
)

db.employees.updateOne(

{Name: “Ian Tayao”},

{$set:{ReportingTo:[‘President’]}}

)
db.employees.findOne(

{Salary:{$gt: 21000.00}}

)
Db.employees.findOne(
{ReportingTo:{$not:{$in: [‘President’]}}}

db.employees.updateMany( {id: 1},{$set: {"contact": {"email": "steve.badiola.gov.ph", "phone": "+1


1234567"}}}, {id: 2},{$set: {"contact": {"email": "jamir.garcia.gov.ph", "phone": "+2 1234567"}}}, {id: 3},
{$set: {"contact": {"email": "reg.rubio.gov.ph", "phone": "+3 1234567"}}}, {id: 4},{$set: {"contact":
{"email": "ian.tayao.gov.ph", "phone": "+4 1234567"}}} )

You might also like