从Firestore读取数据

时间:2019-05-20 12:03:18

标签: firebase kotlin google-cloud-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 ScreenShot

enter image description here

0 个答案:

没有答案