trying to figure out this. Im using firestore and trying to store my random generated numbers/characters when im using .doc() while creating up documents instead of naming them.
Now my problem is i wanna make another collection inside that document. A subcollection that is. How do i go about this? Its super easy when i have a hardcoded variable because then i know directly what document to create it in. But how do i work around it with random generated chars/numbers?
Heres my entire thing
company_id: CompanyID,
})```
firestore.collection('books').doc().set({
company_id: CompanyID,
})
.then(() => {
firestore.collection('books').doc().collection('messages').add({
text: 'hej',
createdAt: firebase.firestore.FieldValue.serverTimestamp(),
myIdNumber,
displayName,
})
})
.catch((error: string) => {
console.error("Error while creating: ", error);
});```