Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

403
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!