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

98
Views
Subcollection in Firestore

I can't create a document in a non existing subcollection.

I have a collection users, with a document that has the userId as Id. In this document I want a subcollection orders

the orders subcollection is not created yet. But you cant create empty subcollections.

So I do this:

const OrderID = 1; //just for testing
const ref = doc(
        db,
        "users",
        getAuth().currentUser.uid,
        "orders",
        OrderID
      );

But that does not work.

How can I do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ok found it OrderID can't be a number. It must be a string. The error I got did not tell me that. It complained about an out of range function.....

const OrderID = 1; //just for testing
const ref = doc(
        db,
        "users",
        getAuth().currentUser.uid,
        "orders",
        OrderID.toString()
      );
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!