1

I have an existing table with data in firebase, it is just a simple string array and not a object array. I want to add string array and push it to the firebase list array. I was thinking to loop through the string array and call the update function but is there a simpler way of doing it?

Updating list in firebase:

  let data = ["charamander", "mew", "onix"]
  await dataRef.update({
    list: firestoreFieldValue.arrayUnion(data)
  })

Firebase structure: Collection -> Words (Doc) -> list enter image description here

1 Answer 1

2

Solution was spread operator

  await dataRef.update({
        wordList: firestoreFieldValue.arrayUnion(...data)
      })
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.