the coder
the coder

Reputation: 420

How to add a value to list field in firebase?

I have a field of type array in my firebase database and I want to add to it new values.

What code I want :

Firestore.instance.collection('lists').document(123).setData({
  'myList': FieldValue.add(**myValue**);
});

Upvotes: 1

Views: 1881

Answers (1)

Igor Kharakhordin
Igor Kharakhordin

Reputation: 9873

This should work:

Firestore.instance.collection('lists').document(123).updateData({
  'myList': FieldValue.arrayUnion(['el1', 'el2'])
});

Upvotes: 6

Related Questions