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

408
Vistas
How to update one Firebase child of existing parent without new key?

I have a data structure like this in Firebase web:

Users:

-KixIFileAu48UrbAI8k  
  --name: Chris  
  --state: 0  
  --contact: www.site.com/emailLink   
-KvxTFdleAu4rUrbAI8z   
-KetdTdWefu4rtrbER0q

I created a Node JS bot that checks whether the state is equal to 0 for each user, and if so, goes to the contact link and grabs their email listed there. From there, I want my bot to change the state from 0 to 1 so that I & the bot know it has been reviewed already.

I can't for the life of me figure out how to update this. It seems like the firebase tutorial asks me to push a new key, which I don't understand.

Why can't I do something like this:

firebase.database().ref('Users').child('state').update("1");

If I try that, I get this:

"Error: Firebase.update failed: First argument must be an object containing the children to replace."

This seems like something super straight forward and yet I can't figure it out.

After that, could I use the same method to push a new (previously non-existent) email child to each user with the email address I got?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

function getUser(Users){
 var keys = Object.keys(Users);
 var User = Users[keys[i]];

  var id = keys[i];

var state = User.state;
var contact = User.contact;

if(contact != "" && contact != undefined){
    console.log("Key:"+id);
firebase.database().ref("Users").child(keys[i]).child("state").set("1");

This ended up fixing the problem. The last line of this code is what I used and it worked great!

over 4 years ago · Santiago Trujillo 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