Vik
Vik

Reputation: 9289

Firebase fetching data based on a particular key value

I am using firebase real time database. 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? I've tried to do the following:

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

but that doesn't work.

Upvotes: 1

Views: 258

Answers (1)

Orlandster
Orlandster

Reputation: 4858

If I got you right, you want to filter your data through the rest 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.

Upvotes: 1

Related Questions