gpt4 book ai didi

android - 在 Kotlin 的 Firestore 中获取 map 的一个值

转载 作者:行者123 更新时间:2023-11-29 22:39:56 24 4
gpt4 key购买 nike

我在 Firestore 中有一个具有这种结构的文档:

Firestore structure

其中 queue 是一个映射。我想获取键值 active inside

val restaurantRef = db.collection("restaurants")
restaurantRef
.get()
.addOnSuccessListener { result ->
var queueStatus = ArrayList<Boolean>()

for (document in result) {
queueStatus.add( ... ) // How do I get the active value in my map here?
}
}

如何在我的 queue 映射中获取 active 的值?

最佳答案

我找到了答案。在 queueStatus.add(...) 行中,将其替换为以下行:

val docMap = document.get("queue") as Map<String, *>
queueStatus.add(docMap.get("active") as Boolean)

关于android - 在 Kotlin 的 Firestore 中获取 map 的一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59116441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com