I have a data structure like:

I want to edit the value of "test" key in "first" object. I followed the document on https://firebase.google.com/docs/firestore/manage-data/add-data
But it did not work for me.
The nodejs code:
var setAda = dbFirestore.collection('users').doc('alovelace').update({         first : {             test: "12345"             } });   The result in firestore: 
The "test2" key was gone. However, I only want to update the value of "test" and keep the "test2".
Any solution for this problem?
According to the link you provided, it says this:
If your document contains nested objects, you can use "dot notation" to reference nested fields within the document when you call update():
Therefore you need to use dot notation to be able to update only one field without overwriting, so like this:
var setAda = dbFirestore.collection('users').doc('alovelace').update({     "first.test": "12345" });   then you will have:
 first   test: "12345"   test2: "abcd" 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With