Firebase Querry

this https query returns all tables
https://hello-world-7aae1.firebaseio.com/users.json?
result : {“u1”:{“age”:21,“name”:“asdf”},“u2”:{“age”:22,“name”:“qwer”},“u3”:{“age”:21,“name”:“zxcv”},“u5”:{“age”:22,“name”:“asdf”}}

this https query returns filtering by name
https://hello-world-7aae1.firebaseio.com/users.json?orderBy=“name”&equalTo=“asdf”
result : {“u1”:{“age”:21,“name”:“asdf”},“u5”:{“age”:22,“name”:“asdf”}}

1>what will be the format of query to filter by name and age
2>what will be the format of query to filter by name or age

fb rules:
{
“rules”: {
“users”:{
“.read”: true,
“.write”: false,
“.indexOn”: [“age”,“name”]
}
}
}
i don’t want to filter after downloading whole json data my DB is large

What output are you expecting for your two required queries ?

It appears you are already getting the data you want back as a json…

i want result where say name = asdf and age = 22
{“u5”:{“age”:22,“name”:“asdf”}}

i want to filter 2 parameters simultaneously not filter in app

Just one record with name and age, or many/all records ?

https://hello-world-7aae1.firebaseio.com/users/u5.json

all records that match the parameter

For example, all users that have age 22 ?

all records where age is say 22 and name asdf it could be more than one

I believe you will need to reorganise your data to do that. See here:

so data something like this:

u1:22
u2:34
u3:22
u4:23

You would also need to add the .value to your IndexOn

This is your API ?
https//hello-world ?

yes read is allowed

I’ll try to explain. Is this https: // an API? https://hello-world-7aae1.firebaseio.com/users.json?

Look orderby and equal.
The documentation says what about these parameters?
Can you filter 2 tags? https://hello-world-7aae1.firebaseio.com/users.json?orderBy="name=&equalTo=“asdf”&orderBy="age"&equalTo=22 ?

don’t think will, help what will the query like

kodular gave firebase real time db all well and good
but no way to run query
what good is db without query using web component to run querry

This should work, can’t test as you seem to have locked down your data…

https://hello-world-7aae1.firebaseio.com/users.json?orderBy="age"&equalTo=22

not running
{
“error” : “orderBy must be a valid JSON encoded path”
}

Please show how you data is set out in Firebase (screenshot of data)

What documentation say about querys ?

1 Like

Able to test now, isn’t this what you want?

https://hello-world-7aae1.firebaseio.com/users.json?orderBy="age"&equalTo=22
{
"u2": {
"age": 22,
"name": "qwer"
},
"u4": {
"age": 22,
"name": "zxcv"
},
"u5": {
"age": 22,
"name": "asdf"
}
}

yes this part works but i want to search all users whose age is 22 and name is asdf