Skip to content

Instantly share code, notes, and snippets.

@khris
Created October 8, 2014 09:57
Show Gist options
  • Save khris/f05dc3d3275ae5e8c7ae to your computer and use it in GitHub Desktop.
Save khris/f05dc3d3275ae5e8c7ae to your computer and use it in GitHub Desktop.
Set a field name in a MongoDB document with dollar sign($)
db.application.update(
{field1: 'value1'},
{$set: {'subdoc.$field_name_with_dollar_sign': 'value2'}}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment