Last active
December 1, 2022 23:30
-
-
Save parkerfoshay/b27da924ba7ec6c80c56bcc96be60b26 to your computer and use it in GitHub Desktop.
updating & deleting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.sales.deleteOne({_id: ObjectId("5bd761dcae323e45a93ccff1")}) | |
db.sales.deleteMany({ storeLocation: {$in: [ 'Denver', 'New York' ]} }); | |
db.sales.deleteMany({}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE FROM sales WHERE id = '1234567'; | |
DELETE FROM sales WHERE storeLocation IN ('Denver', 'New York'); | |
DELETE FROM sales; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.sales.updateOne( | |
{ _id: ObjectId("5bd761dcae323e45a93ccff1") }, | |
{ $set: { storeLocation: "London" } } | |
); | |
db.sales.updateMany( | |
{ purchaseMethod: "Online" }, | |
{ $set: { couponUsed: true } } | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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