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

262
Views
Inserting into Firebase Realtime Database overwrites data instead of appending, how do I get it to append instead of overwriting in js?

I am trying to enter workout information into a Firebase Realtime database from a vue js web app. However, it overwrites data when I try to insert into it. If I enter information for bicep curls and then enter bicep curls again instead of appending it overwrites the original. For example, I want it to be setup like this:

users

  • person a
    • bicep curls -list of data for different days
    • bench press -list of data for different days
  • person b
    • bicep curls -list of data for different days
    • squats -list of data for different days

This is my way of inserting data:

writeUserData: function() {
            const db = getDatabase();
            var data = {
                'weight': this.weight,
                'reps': this.reps,
                'sets': this.sets,
                'date': Date(),
            }
            userRef = ref(db, 'users/',  this.name,  this.workoutType);
            set(userRef, [data]);
        },
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Every time you call set with a reference, it replaces any existing data at that ref.

If you want to create a new unique child nodes under the ref, use push instead of set.

push(userRef, data)

Also see the Firebase documentation on appending to a list of data.

Using an array notation like you're trying won't work unless you first read the existing data from the location. Trying to do this is an antipattern in Firebase though, so I also recommend reading Best Practices: Arrays in Firebase.

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!