Rename nested fields with period and dollar

I have documents in a collection where it has nested fields with period and dollar sign in the field name. I want to rename those field names.

'raw_features': {'0 items|$0.00': [['0 items', 0.766865203825603]],
   'our price': [['$14.95                    - save 25%! *off rrp',

I tried this update command but didn’t work

db.collection.updateOne({'_id': ObjectId('000826efaba4ee3f242cb3ea')}, {$rename : { 'raw_features.0 items|$0.00' : "raw_features.0 items0_00"} } )

Take a look at this command when dealing with field names with embedded reserved characters.

1 Like