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

398
Vistas
Firebase V9, add subcollection to existing doc
const q = getDoc(doc(db, "customers", user.uid));

Hello, this returns a promise in the console.log. I have a customers collection and each user.uid is a document inside it. I want to create a subcollection for each user.uid document, so I can put an object { with some parameters} inside. But how do I create a subcollection called "checkout_sessions" for each document(user.uid). Any help would be appreciated, please, thanks

This is how its done in Firebase v8. by the time of writing the lines the firestore doesnt have a collection called checkout_sessions and this seems to create 1 for each user.uid

const docRef = await db
.collection("customers")
.doc(user.uid)
.collection("checkout_sessions").
add({
 price: priceId,
 and: two,
 more: pairs,
});

I need to create this same subcollection "checkout_sessions" and add data inside in firebase v9, please thank you!!!!!

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

0

Rewriting code to v9 is typically a matter of changing the method calls to the equivalent function calls, and passing in the object as the first parameter.

In your code snippet that'd be:

const docRef = doc(db, "customers", user.uid);
const colRef = collection(docRef, "checkout_sessions")
addDoc(colRef, {
 price: priceId,
 and: two,
 more: pairs,
});
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