Reputation: 163
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?
Upvotes: 0
Views: 48
Reputation: 163
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()
);
Upvotes: 1