In cloud firestore, I want to add the value form to collection A and then all the same value to another collection B, but collection B is inside collection A. Currently I want to get the id of the document while adding the data to collection A and then use this.firestore.collection(A).doc(id).collection(B).add(data), but currently I cannot get the ID of the document This one is my code to get ID when adding data to collection A.
onSubmit(form: NgForm) {
let data = form.value;
lastID = '';
this.firestore
.collection('Users')
.add(data)
.then(function (docRef) {
this.lastID = docRef.id;
});
this.firestore.collection('Users').doc(lastID).collection('profile').add(data);
this.resetForm(form);
}