I already make loop some function to save as a list to Firestore like below:
var documentAttachments = await Firestore.instance
.collection('cs_candidates')
.document(widget.userEntity.email)
.collection('attachments')
.document();
for (FinalUrlModel data in result) {
await Firestore.instance.runTransaction((transaction) async {
await documentAttachments.setData(AttachmentsEntity(
name: data.name,
type: RESUME,
urlName: data.url,
url: AttachmentsHelper.validateUrl(data.url),
).toJson());
});
}
But when I try to save it and checked the data, the data that already saved it to Firestore only the last data. But actually I have 5 data as a list from result.
How to make different documentID so I can save all data without replaced the before data?
Or have any idea to save a list without looping first?
Because I need save all data list from result to Firebase Storage.