1

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

8 Comments

yes you understood correct. however how does startAt will help here? id may be totally random number and does not have to be an ordered. Or take it this way: what id is actually not a number but a unique string which is used as key for each object?
what do you want to achieve? The question says you want to get the record with an id of 2.
my example happen to be bad i would say. How about finding the one with name = b.
just do ?orderByKey="name"&startAt=b
yeah of course you just need to make the call dynamic. replace the value ?orderByKey="name"&startAt=kfljjfsg
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.