Skip to content

Instantly share code, notes, and snippets.

@souzagustavo
Last active August 31, 2018 14:42
Show Gist options
  • Save souzagustavo/6dc7c4e485aefbcdf605fbc19677b8a7 to your computer and use it in GitHub Desktop.
Save souzagustavo/6dc7c4e485aefbcdf605fbc19677b8a7 to your computer and use it in GitHub Desktop.
MongoDB - Updating document values ​​in a array list
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