Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
How to update an "array of objects" with Firestore and Firebase functions?

I have some body data coming into firebase functions as a array ['123','hello','34']

I then process it by doing const data = JSON.stringify(['123','hello','34'])

After i update the firestore data by doing a set

set({testData : firestore.FieldValue.arrayUnion(data)})

Problem is, the entire thing is saved as string in firestore

testData: "['123','hello','34']"

Instead of an array.

testData: 
 0: "123"
 1: "hello"
 2: "34"

My question is how do i get firestore to save it as an array?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are converting it to a string by using stringify(). Try refactoring the code as shown below:

docRef.set({ testData : firestore.FieldValue.arrayUnion(...data) })
// use spread operator here                             ^^^

The documentation (NodeJS) has an example on adding multiple values using arrayUnion.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!