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

105
Views
updating and existing object in firestore database?

In the following example I am updating 2 things. The first thing is an existing array in the db, and the second thing is an existing object. The array pushing is working as it should, but the object has an issue. I mean is there an equivalent for array union to object?

   // Doc model current state before the incoming update.
   data 
   {items :[]}
   {lists : {}}
   
   
   const addObjToClientsArr = async () => {
      const docRef = doc(db, 'data', _authContext.currentUser.uid);
      const payload = selected;
      // Array
      await updateDoc(docRef, { items: arrayUnion(payload) });
      // Obeject
      const payload2 = {[context.id]: [
            { a : 1 },
          ]}
        
       updateDoc(docRef, {
        lists: {
         payload2
      });
    };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It sounds like you want to update a field inside a nested object, which you can do with:

const path = `lists.${context.id}.a`;
await updateDoc(docRef, {
  [path]: 1
})
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!