roysougat
(roysougat)
December 12, 2020, 7:02am
#1
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
TimAi2
(metricrat)
December 12, 2020, 2:42pm
#2
What output are you expecting for your two required queries ?
It appears you are already getting the data you want back as a json…
roysougat
(roysougat)
December 12, 2020, 2:59pm
#3
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
TimAi2
(metricrat)
December 12, 2020, 3:01pm
#4
Just one record with name and age, or many/all records ?
https://hello-world-7aae1.firebaseio.com/users/u5.json
roysougat
(roysougat)
December 12, 2020, 3:03pm
#5
all records that match the parameter
TimAi2
(metricrat)
December 12, 2020, 3:04pm
#6
For example, all users that have age 22 ?
roysougat
(roysougat)
December 12, 2020, 3:05pm
#7
all records where age is say 22 and name asdf it could be more than one
TimAi2
(metricrat)
December 12, 2020, 3:11pm
#8
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
Rogerio_Rios
(Professional Support)
December 12, 2020, 3:18pm
#9
This is your API ?
https//hello-world ?
Rogerio_Rios
(Professional Support)
December 12, 2020, 3:24pm
#11
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 ?
roysougat
(roysougat)
December 12, 2020, 3:26pm
#12
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
TimAi2
(metricrat)
December 12, 2020, 3:27pm
#13
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
roysougat
(roysougat)
December 12, 2020, 3:28pm
#14
not running
{
“error” : “orderBy must be a valid JSON encoded path”
}
TimAi2
(metricrat)
December 12, 2020, 3:30pm
#15
Please show how you data is set out in Firebase (screenshot of data)
Rogerio_Rios
(Professional Support)
December 12, 2020, 3:30pm
#16
What documentation say about querys ?
TimAi2
(metricrat)
December 12, 2020, 3:40pm
#19
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"
}
}
roysougat
(roysougat)
December 12, 2020, 3:42pm
#20
yes this part works but i want to search all users whose age is 22 and name is asdf