I use the Firestore reference data type to store a link to a user, as shown in the screenshots below
User Link

User Collections

When I try to request this data, I get a ClassCastException (I tried to use it for String just for the sake of it).
code
//.. this function reads data from DocumentSnapshot //.. and converts to an Organization private fun DocumentSnapshot.toOrganization(): Organization { //.. some code (this.data["members"] as ArrayList<HashMap<String, Any>>).map { toOrgMember(it) }) //.. more code } fun toOrgMember(map: Map<String, Any>): OrgMember { //map["user"] as String throws ClassCastException. Refer first screenshot return OrgMember(map["id"] as Long, UserRef(map["user"] as String), map["type"] as String, asJobTitlesList(map["jobTitles"] as String)) }
Stacktrace
10-14 20:31:17.503 15569-15569/com.ab W/System.err: Caused by: java.lang.ClassCastException: com.google.android.gms.internal.zzegf cannot be cast to java.lang.String 10-14 20:31:17.504 15569-15569/com.ab W/System.err: at feature.model.core.CoreUtilsKt.toOrgMember(CoreUtils.kt:28) 10-14 20:31:17.504 15569-15569/com.ab W/System.err: at feature.model.organization.OrgRemoteKt.toOrganization(OrgRemote.kt:55)
In which class should I use the reference data type? ( com.google.android.gms.internal.zzegf seems like an inner class that should not be used)
At the moment, I have not found any example in the docs for the reference type. Any help would be appreciated.
source share