首页 > 解决方案 > 从 Firestore 读取数据

问题描述

我尝试从 Firestore 获取数据并将数据保存在MutableList其中,并且我使用了与存储数据相同的模型。当我按照代码他们正确读取数组的大小但不将数据读取为空但数据库中的值不是空的。

我需要帮助:

fun getDataQuestions(onComplete: (MutableList<QuestionModel>) -> Unit): ListenerRegistration {
        val id = FirebaseAuth.getInstance().currentUser!!.uid
        val doc = FirebaseFirestore.getInstance()
            .collection("employerUsers").document(id).collection("Question").whereEqualTo("employeeID",this.EmployeeId )
        return doc.addSnapshotListener { querySnapshot, firebaseExeption ->
            Log.w("firebaseExeption", "" + firebaseExeption)
            Log.i("firebaseExeption", "" + querySnapshot)
            onComplete(querySnapshot!!.toObjects(QuestionModel::class.java))

        }
    }

Firestore 屏幕截图

在此处输入图像描述

标签: firebasekotlingoogle-cloud-firestore

解决方案


推荐阅读