1

Current data in firestore

fruits: { apple: 20, orange: 10 } 

Now how to add more fruits to the fruits field without overwriting apple and orange

Fruits to be added

fruits: { pineapple: 20, cherry: 10, banana: 10 } 

Tried doing this but apple and orange gets removed

batch.update(fs.doc(`config/254868`), { fruits: fruits, }); 
1
  • 2
    You need to use dot notation to call out each individual nested field to update. What you are doing right now is specifying an entirely new map to update the field called "fruits". Commented Jun 3, 2022 at 15:44

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.