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

181
Views
Firestore, adding value to an existing array field

I want the new ph value to be added in the arraylist but instead, it keep updating the first value of the arraylist

my firestore

var insBtn = document.getElementById("InsBtn");

 async function AddDocument_CustomID() {
    var ref = doc(db,"pHvalue", "pH");

     await setDoc(
        ref, {
            pH: [pH.value]
        });
}


insBtn.addEventListener('click', AddDocument_CustomID);

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

0

If you want to add a new unique value to the existing values in the pH array, you can use an array-union operation:

updateDoc(ref, {
    pH: arrayUnion(pH.value)
});

If you instead want to add a possibly non-unique value to the end of the pH array, you will instead have to:

  1. Load the document into your application and get the existing pH array from it.
  2. Add the new item to the end of the array.
  3. Write the entire array back to the database.
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!