Update an Array of Embedded Documents with Dot(.) field value


I am trying to update one of the Arrays of Embedded documents which contains the dot(.) in the Field name. The update is not happening instead it’s creating a new field in the database

Incorrect Field added in MongoDB Atals,
“303” : {
“2499999999999” : {
“premiumPrice” : 250

Below is the update query captured from my client application running on Java(Driver version 4.2),

“updates”: [{“q”: {“worldId”: “492d68dc-c732-478b-a526-b67782e97838”}, “u”: {"$set": {“stories.test-shop-content.steps.0.entities.-1431655765.303.2499999999999.premiumPrice”: 250}}}]}

We have recently migrated our servers from MongoDB compass(3.6.2 version) to Mongo Atlas(4.4 version).

The same code worked properly when we are using MongoDB compass.

Can you let me know how to update the field value when the field name contains (.) in it?

Let me know if you need any further information. :slight_smile:

Did you intend to always have a field with a dot in it? Because usually "." indicates subfield/array traversal in MDB query language, having it as part of field name is problematic (as you just discovered).

Having said that, there are workarounds available for this if you absolutely must keep this schema.