I have an app that uses firestore, when the user clicks a button I add a document, in which after its creation, I also add its documentId in a field , which is an alphanumeric string generated by firestore. My problem is that if a user clicks the button without internet, then closes the app and opens it with an internet connection the document gets created, but of course its Id inside it is null, since the programm stopped executing. Is there a way I can persist that?
for example
DocumentReference documentReference =
await FirebaseFirestore.instance.collection('sth').add(map); //map has a 'docId' key
await FirebaseFirestore.instance
.collection('sth')
.doc('${documentReference.id}')
.update({'docId': documentReference.id});
The update one does not have offline persistence, is there any way around it?
set
instead ofupdate
– Dima Rostopira