update to array firbase code example
Example 1: firestore update array
let washingtonRef = db.collection('cities').doc('DC');
let arrUnion = washingtonRef.update({
regions: admin.firestore.FieldValue.arrayUnion('greater_virginia')
});
let arrRm = washingtonRef.update({
regions: admin.firestore.FieldValue.arrayRemove('east_coast')
});
Example 2: firestore update map
let initialData = {
name: 'Frank',
age: 12,
favorites: {
food: 'Pizza',
color: 'Blue',
subject: 'recess'
}
};
let updateNested = db.collection('users').doc('Frank').update({
age: 13,
'favorites.color': 'Red'
});