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

184
Views
How to create and push an object in to firebase array?

My current logic is the following creating adding a document with a user id in to users collection, and push the first object, then on the second call I want to be able to update the excising array with a new object.

const docRef = doc(db, 'user', _authContext.currentUser.uid);
const payload = { items: [{item1 : 1}] };
await setDoc(docRef, payload);


// New array after update (second call of the function)
items: [{item1 : 1}, {item2 : 2}]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you're looking for:

await updateDoc(docRef, { items: arrayUnion({ item2: 2 }) });

Also see the Firebase documentation on adding items to an array.

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!