TSR
TSR

Reputation: 20396

How to update the propriety of a field objects in a firestore document?

I have this database. I want to update channels 2 to false.

enter image description here I tried:

db.collection('preferences').doc(user_id).update({communication:{'1':{channels:{'2':false}}}})

But as a result, channel 4 disappears:

enter image description here

Upvotes: 0

Views: 25

Answers (1)

Philip
Philip

Reputation: 871

You can update the following structure with dot notation.

firebase
  .firestore()
  .collection("preferences")
  .doc("user_id")
  .update({
    "communication.1.channels.2": false
  });

Upvotes: 2

Related Questions