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

161
Vistas
Javascript - Error Message : db.collection is not a function && How to check whether the write batch whether successfully upload the data to firestore
        // Get a new write batch
        const batch = writeBatch(db);

        var TransactionRecordRef = db.collection("TopUpRecord").doc();
        batch.set(TransactionRecordRef, {
            Amount: FinalTopUpAmount,
            DateTime: serverTimestamp(),
            StudentID: StudentID,
        });
               

        var TopUptoUserRef = db.collection("user").doc(UserID);
        batch.update(TopUptoUserRef, { "studentAmount": UserTotalAmount });

        batch.commit();

Hi, the above is my code that needs to use write batch to create a new document on TopUpRecord and update the user's amount. Now I have two questions that I need to ask one is how can I know whether the batch successfully updates the record to the firestorm and I also found that my above code has an error which "db. the collection is not a function" Is anyone why this issue happened?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're mixing the v8-and-before namespaced syntax (db.collection("TopUpRecord").doc()) with the v9-and-up modular syntax (writeBatch(db)), which isn't possible.

In the modular syntax, that line would be:

const TransactionRecordRef = doc(collection(db, "TopUpRecord"));

Also see the v9 examples in the Firebase documentation, and the upgrade guide.

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