I started working with mongodb a month ago and still having problems working with complex queries but anyway, can anyone help me rewrite this SQL update query to mongoDB query? UPDATE teams SET active = 0 WHERE id = 3 AND leader_id IN (SELECT id FROM users WHERE organization = 'Accounting Department')
Below is my sample data.
Teams Collection:
{
id: 1,
name: "white horse",
leader_id: "L1",
active: 1
},
{
id: 2,
name: "green hornets",
leader_id: "L2",
active: 1
},
{
id: 3,
name: "pink flaminggo",
leader_id: "L3",
active: 1
}
Users Collection:
{
id: "L1",
name: "John Doe",
organization: "Software Development",
active: 1
},
{
id: "L2",
name: "Peter Piper",
organization: "Software Development",
active: 1
},
{
id: "L3",
name: "Mary Lamb",
organization: "Accounting Department",
active: 1
}