Firestore获取DocumentSnapshot的字段值 [英] Firestore get DocumentSnapshot's field's value

查看:127
本文介绍了Firestore获取DocumentSnapshot的字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个Firebase Firestore数据库,该数据库为与右侧集合相对应的文档检索了DocumentSnapshot并将其存储在document变量中,那么如何在以下位置检索该DocumentSnapshot中的值:字段用户名"?该字段具有字符串值.

If I have a Firebase Firestore database which I have retrieved a DocumentSnapshot for the document corresponding to the collection on the right and stored in a document variable, then how could I retrieve the value in that DocumentSnapshot at the field "username"? The field has a string value.

推荐答案

DocumentSnapshot 具有

DocumentSnapshot has a method getString() which takes the name of a field and returns its value as a String.

String value = document.getString("username");

这篇关于Firestore获取DocumentSnapshot的字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆