Last active
August 31, 2018 14:42
-
-
Save souzagustavo/6dc7c4e485aefbcdf605fbc19677b8a7 to your computer and use it in GitHub Desktop.
MongoDB - Updating document values in a array list
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.movement.insert({ | |
"lot": "00467", | |
"production": true, | |
"files": [{ | |
"extension": ".txt", | |
"name": "test1", | |
"size": 5811 | |
}, | |
{ | |
"extension": ".csv", | |
"name": "test2", | |
"size": 51 | |
}, | |
{ | |
"extension": ".pdf", | |
"name": "test3", | |
"size": 897897 | |
}] | |
}); | |
db.movement.updateOne( | |
{ "lot" : "00467" , "production" : true, "files.extension" : ".txt" }, | |
{ "$set" : { "files.$.extension" : ".pdf" } }, | |
{ "multi" : true } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment