Мне нужно обновить записи, когда документ уже существует в FirebaseFirestore, вот мой код
call.enqueue(new Callback<DoctorsResponse>() {
@Override
public void onResponse(@NonNull Call<DoctorsResponse> call, @NonNull Response<DoctorsResponse> response) {
progressDialog.setTitle("Uploading...");
progressDialog.show();
if (response.isSuccessful()){
Log.e("@@Success", String.valueOf(response.body().getData()));
docDetailsList.addAll(response.body().getData().getMemberData());
MemberDatum memberDatum = new MemberDatum();
for (int i =0; i<response.body().getData().getMemberData().size(); i++){
String queryforbranch = FirebaseFirestore.getInstance().collection("BranchWiseList").document().getId();
memberDatum.setDoctorId(queryforbranch);
memberDatum.setMbbsCollegeName(docDetailsList.get(i).getMbbsCollegeName());
memberDatum.setMbbsYear(docDetailsList.get(i).getMbbsYear());
memberDatum.setId(docDetailsList.get(i).getId());
memberDatum.setWuid(docDetailsList.get(i).getWuid());
memberDatum.setDocName(docDetailsList.get(i).getDocName());
memberDatum.setDocFatherName(docDetailsList.get(i).getDocFatherName());
memberDatum.setDocbloodGroup(docDetailsList.get(i).getDocbloodGroup());
memberDatum.setDocAddress(docDetailsList.get(i).getDocAddress());
memberDatum.setDocDistrict(docDetailsList.get(i).getDocDistrict());
memberDatum.setDocState(docDetailsList.get(i).getDocState());
memberDatum.setDocPrimaryMob(docDetailsList.get(i).getDocPrimaryMob());
memberDatum.setDoctDesignation(docDetailsList.get(i).getDoctDesignation());
memberDatum.setDocEmail(docDetailsList.get(i).getDocEmail());
memberDatum.setRmcNumber(docDetailsList.get(i).getRmcNumber());
memberDatum.setImaMember(docDetailsList.get(i).getImaMember());
memberDatum.setDocPopularName(docDetailsList.get(i).getDocPopularName());
memberDatum.setRmcRegistrationDate(docDetailsList.get(i).getRmcRegistrationDate());
memberDatum.setDocDob(docDetailsList.get(i).getDocDob());
memberDatum.setBranch(docDetailsList.get(i).getBranch());
memberDatum.setDateOfMarriage(docDetailsList.get(i).getDateOfMarriage());
memberDatum.setDocCity(docDetailsList.get(i).getDocCity());
memberDatum.setDocSpeciality(docDetailsList.get(i).getDocSpeciality());
memberDatum.setDocgender(docDetailsList.get(i).getDocgender());
memberDatum.setDoctCategory(docDetailsList.get(i).getDoctCategory());
memberDatum.setDoctImage(docDetailsList.get(i).getDoctImage());
memberDatum.setEmployeetype(docDetailsList.get(i).getEmployeetype());
memberDatum.setHospitalAbout(docDetailsList.get(i).getHospitalAbout());
memberDatum.setHospitalAddress(docDetailsList.get(i).getHospitalAddress());
memberDatum.setHospitalDistrict(docDetailsList.get(i).getHospitalDistrict());
memberDatum.setHospitalEmail(docDetailsList.get(i).getHospitalEmail());
memberDatum.setHospitalImageOne(docDetailsList.get(i).getHospitalImageOne());
memberDatum.setHospitalImageTwo(docDetailsList.get(i).getHospitalImageTwo());
memberDatum.setHospitalImageThree(docDetailsList.get(i).getHospitalImageThree());
memberDatum.setHospitalImageFour(docDetailsList.get(i).getHospitalImageFour());
memberDatum.setHospitalImageFive(docDetailsList.get(i).getHospitalImageFive());
memberDatum.setHospitalImageSix(docDetailsList.get(i).getHospitalImageSix());
memberDatum.setHospitalName(docDetailsList.get(i).getHospitalName());
memberDatum.setHospitalPhone(docDetailsList.get(i).getHospitalPhone());
memberDatum.setHospitalSpecilities(docDetailsList.get(i).getHospitalSpecilities());
memberDatum.setHospitalState(docDetailsList.get(i).getHospitalState());
memberDatum.setHospitalWebsite(docDetailsList.get(i).getHospitalWebsite());
memberDatum.setIsIMAMember(docDetailsList.get(i).getIsIMAMember());
memberDatum.setHospitalWebsite(docDetailsList.get(i).getHospitalWebsite());
memberDatum.setAddSpecialityModels(docDetailsList.get(i).getAddSpecialityModels());
memberDatum.setOrganizationModels(docDetailsList.get(i).getOrganizationModels());
memberDatum.setSuperSpecialityModels(docDetailsList.get(i).getSuperSpecialityModels());
Log.e("@@Docname",docDetailsList.get(i).getDocName() );
FirebaseFirestore.getInstance().collection("BranchWiseList").document(memberDatum.getDoctorId()).set(memberDatum).addOnCompleteListener(task -> {
if (task.isSuccessful()) {
progressDialog.dismiss();
} else {
Toast.makeText(ImportBranchWise.this, "Something went wrong", Toast.LENGTH_SHORT).show();
}
});
Когда я снова нажму на Api, я получу двойные записи с другим идентификатором документа, который не обновляется. Я пытался собновлять запросы уже, помогите мне, я был бы признателен за каждый ответ на StackOverflow заранее спасибо