-
Hi. I just started using this recently and firstly want to say thank you to all the maintainers for making this happen. My question is about updating nested fields without overriding the whole field completely. Is there a way to do it in Godot? Supposing I had this data in the database:
I would like to update the values of nested-field2 without deleting nested-field1. In the wiki, it says collection.update will update only the fields specified and leave the others untouched. But when I tried, it would override "field1" completely, thus deleting "nested-field1" and just replacing "nested-field2" with what I gave it. I saw some examples from other languages using firebase where they used dot notation to update a specific nested field only. So I tried putting the add_or_update_field method first argument path to "field1.nested-field2" but dot notation or using a forward slash didn't work. The behavior was strange, sometimes the write was successful but no changes were made. Sometimes the write gave an error. I looked through the discussions and didn't see anything about this. Hopefully I didn't just overlook something simple. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
That might just be a bug actually. I'll have to look into it. |
Beta Was this translation helpful? Give feedback.
Just an update so if anyone in the future sees this, they can benefit from what I ended with.
It seems escaping field names doesn't quite work. It reports success but nothing changes in the database. Using simple field names works fine. So instead I generated a unique ID to use as the field name and kept a look up table of unique IDs to what I originally planned to put, which has characters that aren't allowed without escaping.
See https://firebase.google.com/docs/firestore/quotas#limits for more information. Under "Constraints on field paths", it describes what counts as a simple field name.
For the issue of overriding, it seems like only the very first level you can add and update witho…