FirestoreKMP
FirestoreKMP copied to clipboard
Batch write - not working
I am getting StackOverflow exception when trying to commit a batch.
My code is as follows :-
override suspend fun insertAll(list: List<PostSiteResponse>) {
val userId = prefs.getCurrentUserId() ?: return
val siteRef = firestore.collection(FirebaseConstants.TABLE_USERS)
.document(userId.toString())
.collection(FirebaseConstants.TABLE_SITES)
val batch = firestore.batch()
list.forEach {
val obj = it.toSite()
val map = Mapper.mapNullable(obj)
batch.set(siteRef.document(it.locationId.toString()), map , SetOptions.Merge)
}
batch.commit_()
}
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.guardso_new, PID: 28090 java.lang.StackOverflowError: stack size 8MB at co.touchlab.firebase.firestore.WriteBatchKt.set(Unknown Source:2) at co.touchlab.firebase.firestore.WriteBatchKt.set(WriteBatch.kt:14)