Skip to content

Instantly share code, notes, and snippets.

@parkerfoshay
Last active December 1, 2022 23:30
Show Gist options
  • Save parkerfoshay/b27da924ba7ec6c80c56bcc96be60b26 to your computer and use it in GitHub Desktop.
Save parkerfoshay/b27da924ba7ec6c80c56bcc96be60b26 to your computer and use it in GitHub Desktop.
updating & deleting
db.sales.deleteOne({_id: ObjectId("5bd761dcae323e45a93ccff1")})
db.sales.deleteMany({ storeLocation: {$in: [ 'Denver', 'New York' ]} });
db.sales.deleteMany({})
DELETE FROM sales WHERE id = '1234567';
DELETE FROM sales WHERE storeLocation IN ('Denver', 'New York');
DELETE FROM sales;
db.sales.updateOne(
{ _id: ObjectId("5bd761dcae323e45a93ccff1") },
{ $set: { storeLocation: "London" } }
);
db.sales.updateMany(
{ purchaseMethod: "Online" },
{ $set: { couponUsed: true } }
);
UPDATE sales SET storeLocation = 'London' WHERE id = '1234567';
UPDATE sales SET couponUsed = true WHERE purchaseMethod = 'Online';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment