Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda