简体   繁体   English

Firebase 根据特定键值获取数据

[英]Firebase fetching data based on a particular key value

I am using firebase real time database.我正在使用 firebase 实时数据库。 My data is mostly an array of records.我的数据主要是一组记录。 For example:例如:

opty = [ {"id":1,"name":"a"}, {"id":2, "name": "b"}]

I can access the entire dataset using:我可以使用以下方法访问整个数据集:

https://<my project id>.firebaseio.com/opty.json

How do I fetch the record with an id of 2 here?如何在此处获取id为 2 的记录? I've tried to do the following:我尝试执行以下操作:

https://<my project id>.firebaseio.com/opty.json?OptyId=2

but that doesn't work.但这不起作用。

If I got you right, you want to filter your data through the rest API.如果我猜对了,您想通过其余 API 过滤数据。

To achieve that you can use the usual filter parameters as query strings:为此,您可以使用常用的过滤器参数作为查询字符串:

https://<my project id>.firebaseio.com/opty.json?orderByKey="id"&startAt=2'

Learn more here .在此处了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM