Reputation: 3138
I'm using Firebase Cloud database. This question is similar to the previous one but now I'm interested in DocumentReferences
. I queried a collection and got a list of documents. Each document contains a field cars
which contains DocumentReferences
. Each DocumentReference
references a document that represents a car. Given the carsPath
which is a path to the car document, I want to remove the DocumentReferences
in that list. I'm using WriteBatch
. If cars
would contain just the paths, it would be easy by using:
batch.update(snapshot.getReference(), "cars", FieldValue.arrayRemove(carPath));
Is there a way to do something similar if we have DocumentReferences
instead of Strings
?
Upvotes: 0
Views: 51
Reputation: 317958
Just pass DocumentReference object instead of a string to FieldValue.arrayRemove()
. The path of the reference must match exactly what's in the array.
Upvotes: 1