I want to create multiple documents inside the single or same collection in Firestor. The issue is when I can call the addTeacherBasicDetails() method, so create the perfect but after that, I can call the addTeacherAddressDetails() method, so it can not work or replace all the fields with the current method field. I have also attached the Firestore screenshot for creating this database.
Future addTeacherBasicDetails({required var emailId}) async {
await databaseReference.collection(SMFirebaseParam.teacher)
.doc(emailId)
.collection(SMFirebaseParam.information).doc(SMFirebaseParam.basic_details).set({
SMFirebaseParam.name: edTeacherName.text,
SMFirebaseParam.email: emailId,
SMFirebaseParam.aadhar_card: edTeaAadharCard.text,
SMFirebaseParam.mobile_no: edTeaMobile.text,
SMFirebaseParam.dob: edTeaDOB.text,
SMFirebaseParam.gender: teaGender
}).whenComplete((){
addTeacherAddressDetails(emailId: emailId);
});
}
Future addTeacherAddressDetails({required var emailId}) async {
await databaseReference.collection(SMFirebaseParam.teacher)
.doc(emailId)
.collection(SMFirebaseParam.information).doc(SMFirebaseParam.residential).set({
SMFirebaseParam.address: edTeaAddress.text,
SMFirebaseParam.district: edTeaDistrict.text,
SMFirebaseParam.state: edTeaState.text,
SMFirebaseParam.pincode: edTeaPinCode.text,
SMFirebaseParam.per_address: edTeaPerAddress.text,
SMFirebaseParam.per_district: edTeaDistrict.text,
SMFirebaseParam.per_state: edTeaPerState.text,
SMFirebaseParam.per_pincode: edTeaPerPinCode.text,
},SetOptions(merge: true)).catchError((onError){
SmPrint(name: "CheckError", value: onError.toString());
});
}