How can i search in firebase by different fields?

hello

i have this structure in firebase in which i search by "PN" would it be possible to search also by "compatible"?

these are the blocks that I use for the search

thanks in advanced

Once you have the data, you can search by the key you want.

Just as you are searching by PN, by doing the same, you can search by Compatible.

I'm sorry but I don't understand what you're saying, when I try to search I get the following in the app, I can only search by PN which is the list that you can see in the image

Here you have an example (you have a lot of them in the community) similar to yours. Once you call to GetValue for you tag "recambios" you can get any info:

Also, if you want to get firebase to do some of the hard work:

https://firebase.google.com/docs/database/rest/retrieve-data#section-rest-reading-data-get

now when i search for 12GYY it shows me in the red box what is marked in red in firebase

what I would like to do is to type 529FG and find it in the database structure.

image

529FG is not a Tag/Key so, you will have to get all the info and then search it in that recovered data or, to do what @TIMAI2 told you and implement some type of callback in Firebase (via JSONP) so that it does the job for you.

How much data will you have (eventually), how many records ?

This does everything you have asked for:

image

image

You do have to download all the data to the app. Firebase realtime database does not provide for specific queries like sql / in the way you might expect.

I tell a lie. It is possible to search on a value and return the data...

RULES (demo)

    "recambios": {
         ".read": true,
         ".write": true,
         ".indexOn" : [".value","Compatible","Description","PN"]
     },

hi Timai2

I have tried what you told me but the following occurs:

  • it always downloads in the labels the last one, the rest NOT.
  • when I click on search, it does not find anything, is it possible that it is because it does not download all the data locally ? because if I search for the last data, which is the one that has been downloaded, it DOES work.

any other idea ?

thanks in advanced

What does your responseContent look like? Put it to a label.

It should look like this:

{"234BCD":{"Compatible":"BCD234","Description":"2TB HDD","PN":"234BCD"}}
(from my example data)

IN LABEL

when I search I get this error in the same label

Have you set the indexes in the rules like I showed above ? You need these to be able to do any filtering.

yes

you dont have the same...

"recambios": {
     ".read": true,
     ".write": true,
     ".indexOn" : [".value","Compatible","Description","PN"]
 },

modified
now it does not give error but it does not search, it always shows the last data again.

when i try to get / set in firebase i get an error, this error appears since I added recambios in the firebase rules.