File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,14 @@ async function updateDocumentArray(db) {
228228 const removeRes = await washingtonRef . update ( {
229229 regions : admin . firestore . FieldValue . arrayRemove ( 'east_coast' )
230230 } ) ;
231+
232+ // To add or remove multiple items, pass multiple arguments to arrayUnion/arrayRemove
233+ const multipleUnionRes = await washingtonRef . update ( {
234+ regions : admin . firestore . FieldValue . arrayUnion ( 'south_carolina' , 'texas' )
235+ // Alternatively, you can use spread operator in ES6 syntax
236+ // const newRegions = ['south_carolina', 'texas']
237+ // regions: admin.firestore.FieldValue.arrayUnion(...newRegions)
238+ } ) ;
231239 // [END firestore_data_set_array_operations]
232240
233241 console . log ( 'Update array: ' , unionRes , removeRes ) ;
You can’t perform that action at this time.
0 commit comments