Skip to content

Instantly share code, notes, and snippets.

@zohar
Created February 26, 2015 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zohar/426b60e1d73709bc3c94 to your computer and use it in GitHub Desktop.
Save zohar/426b60e1d73709bc3c94 to your computer and use it in GitHub Desktop.
Find and replace an element in an array in a sub document
// after.2.value - becaus ewe know exactly what to look for
db.test.update({after:{$elemMatch:{"type":"password"}}},{$set:{"after.2.value":'xxxxx'}},{multi:true, upsert:false});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment