如何获取Firebase Firestore Android中某个字段的值? [英] How to get value of some field in firebase firestore android?

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

问题描述

像上一个问题一样,我想获取Firebase Firestore中某个字段的值,而不是使用 DocumentSnapshot

Like upper question, i want to get value of some field in firebase firestore instead of all document with DocumentSnapshot

在SQL SELECT col_1, col_2, col_3 FROM table_name

我该怎么办?

谢谢您的帮助.

推荐答案

Cloud Firestore客户端SDK始终读取并返回完整文档.无法读取文档中字段的子集.

The Cloud Firestore client-side SDKs always read and returns full documents. There is no way to read a subset of the fields in a document.

您可以检索整个文档,然后处理DocumentSnapshot以仅使用您感兴趣的字段.但这意味着您使用的带宽超出了需要.如果您的应用经常出现这种情况,请考虑创建一个辅助集合,其中每个文档仅包含您感兴趣的字段.

You can retrieve the entire document, and then process the DocumentSnapshot to just use the fields you're interested. But this means you're using more bandwidth than needed. If this is a regular occurrence for your app, consider creating a secondary collection where each document contains just the fields you're interested in.

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

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