【发布时间】:2019-07-23 09:57:22
【问题描述】:
我的数据结构为:
val drinks = hashMapOf(
"cola" to hashMapOf(
"price" to 36,
"amount" to 15
)
)
我使用 firestore 并想检索价格。
db.collection("category").document("drinks").get()
.addOnSuccessListener {documentSnapshot->
documentSnapshot.data?.forEach {
//it -> Map.Entry<String!,Any!>
Log.d(TAG, "for each data: ${it.key} ${it.value}")
}
if (documentSnapshot != null && documentSnapshot.exists()) {
Log.d(TAG, "read data: ${documentSnapshot["sultan"]}")
} else {
Log.d(TAG, "Current data: null")
}
}
我尝试将其转换为对象列表,但没有任何帮助
【问题讨论】:
-
请将您的数据库结构添加为屏幕截图并指明您想要获取的确切数据。也请回复@AlexMamo
标签: android kotlin google-cloud-firestore