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

250
Vistas
how to use firebase.database().transaction() method efficiently in expo react native?

I am trying to get the orderid that I have stored on the Realtime Database of Firebase. For getting the data I have been using the firebase.database().transaction() method to avoid use conflicts between realtime use.

All I am trying to do is that get the id to assign it to the current order, then increment it by +1, and then return it to the firebase again. But the problem is that whenever I try to assign that value through the transaction method, I get a null or undefined object.

It does increment the value stored on firebase, but doesn't give an appropriate value to assign to the order object.

So, what can I do to get this done more efficiently?

here's the code I have been using to get the job done:

await firebase.database().ref().child("Order_Id").transaction((value) = > {
  //Sending data to firebase to book the order 
  firebaseRef.child(value).set({
    Appliance_Name: item.title,
    Service_Requested: orderData.serviceType,
    Image: orderData.uploadedImage,
    User_Problem: orderData.problem,
    Location: orderData.latitude + " , " + orderData.longitude,
    Status: "Booked",
    Time: dateTime,
    Assign: ""
  });
  return value + 1;
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It seems that you want to write to two different nodes of your RTDB in a transaction mode: firebase.database().ref().child("Order_Id") and firebaseRef.child(value).

Therefore the transaction needs to apply on a common ancestor of these two nodes. As explained in the doc, the update function (i.e. (value) = > {} in your case) needs to takes the current state of the data (value) as an argument and returns the new desired state you would like to write.", i.e. the new value of the data tree for this common ancestor node.

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