DocumentReference washingtonRef = db.collection("cities").document("DC");
// Atomically add a new region to the "regions" array field.
ApiFuture<WriteResult> arrayUnion =
washingtonRef.update("regions", FieldValue.arrayUnion("greater_virginia"));
System.out.println("Update time : " + arrayUnion.get());
// Atomically remove a region from the "regions" array field.
ApiFuture<WriteResult> arrayRm =
washingtonRef.update("regions", FieldValue.arrayRemove("east_coast"));
System.out.println("Update time : " + arrayRm.get());
$cityRef = $db->collection('samples/php/cities')->document('DC');
// Atomically add a new region to the "regions" array field.
$cityRef->update([
['path' => 'regions', 'value' => FieldValue::arrayUnion(['greater_virginia'])]
]);
// Atomically remove a region from the "regions" array field.
$cityRef->update([
['path' => 'regions', 'value' => FieldValue::arrayRemove(['east_coast'])]
]);
city_ref = db.collection(u'cities').document(u'DC')
# Atomically add a new region to the 'regions' array field.
city_ref.update({u'regions': firestore.ArrayUnion([u'greater_virginia'])})
# // Atomically remove a region from the 'regions' array field.
city_ref.update({u'regions': firestore.ArrayRemove([u'east_coast'])})
city_ref = firestore.doc "#{collection_path}/DC"
# Atomically add a new region to the 'regions' array field.
city_ref.update({ regions: firestore.field_array_union("greater_virginia") })
# Atomically remove a region from the 'regions' array field.
city_ref.update({ regions: firestore.field_array_delete("east_coast") })