Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

261
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda