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

106
Visualizações
Firebase arrayRemove takes very long time in modular version

I'm refactoring my firebase code to support the modular firebase version.

After I refactored the "arrayRemove" function, I noticed that it started to take a very long time to execute. Something about 1 minute. At v8, that was about 1 seconds

Here is my code:

  const userRef = doc(db, 'users', userId)
  try {
    await updateDoc(userRef, {
      items: arrayRemove(itemId),
    })

    console.log('REMOVED')
  } catch (error) {
    console.log(error)
  }

Execution of this code takes around one minute. The same action with the same data in the same environment for the older version takes about one second. The rest functions works fast.

Firebase version: 9.6.1

Any ideas why it takes so long and how to make it faster?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

After reading article "Best Practices: Arrays in Firebase"

I found that practice:

to remove keys, we save the entire array instead of using .remove()

So... I removed item in my code, then updated array and it took less than a second!

  // removing item I need to remove at my local array
  const updArr = arr(
    (item) => item !== itemId
  )

  const userRef = doc(db, 'collection', 'id')

  // updating array
  await updateDoc(userRef, {
    gifts: updArr,
  })

// p.s. Obviously, there is some bug at arrayRemove function, but actually we don't have to use that function 🤫

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