Overview - Array update operations (arrayUnion, arrayRemove)
What is it?
Array update operations in Firebase let you add or remove items from an array stored in a database document without replacing the whole array. arrayUnion adds new unique items, while arrayRemove deletes specified items. These operations happen atomically, meaning they complete fully or not at all, keeping data safe and consistent.
Why it matters
Without these operations, updating arrays would require reading the entire array, changing it in your app, and writing it back. This risks overwriting changes made by others at the same time, causing data loss or errors. Array update operations solve this by letting you safely change arrays directly on the server, even when many users update data simultaneously.
Where it fits
Before learning this, you should understand basic Firebase Firestore concepts like documents, collections, and fields. After this, you can explore more complex data updates, transactions, and security rules that control who can update data.