Created
August 23, 2024 04:05
-
-
Save astleychen/4275a1565825bbaf13fd1592214a773d to your computer and use it in GitHub Desktop.
MongoDB - Rename Fields
This file contains hidden or 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
use("accounts"); | |
db.getCollection("users").updateMany({}, [{ $set: { "address.city": "$address.county", "address.dist": "$address.district" } }], { upsert: true }); | |
db.getCollection("sales").updateMany({}, { $rename: { "nested.new": "nested.country" } }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment