Skip to content
This repository was archived by the owner on Jun 2, 2022. It is now read-only.
This repository was archived by the owner on Jun 2, 2022. It is now read-only.

Batch write - not working #3

@rakeshparveen5

Description

@rakeshparveen5

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions