I have a Firebase array that looks like this
categories:[{rating: 1, name: 'abc'}, {rating: 2, name: 'xyz'}]
How can I update the element with name 'abc' for example to make it something like this {rating: 3, name: 'abc'}
I tried the below but it adds an element to the array as it considers it unique due to the different rating value.
var ref = _db.collection('reports').doc(user.uid);
const data = { categories: FieldValue.arrayUnion([{"name": 'abc', "rating": 3}]) }
ref.set(data, SetOptions(merge: true));