Queries in Firebase

Hi guys,

Could you help me with implementing queries in firebase?

For example getting records from a table where employee id =xxx.

@Mevi

Also tagging you @JOHN_WORSHAM because you’re one of the best who has implemented firebase.

You need to enable Indexing on Firebase side.
In my app I want to search for Users by name or user id (UID) so I set indexing on my “Users” data:


When a user types in a Name to search, this is my query (as a formula) to that User data in a HTTP GET request:

Now the data returned is going to be Objects so if there is a match then I get the output (in a formula) at index 0 (first item returned) and just use that (ignoring the binding warnings):

Edit: Note above I wrap the outputs with “VALUES” because the data returned isnt in a List of Objects format, so you have to use “VALUES” to transform that pile of Objects into a List.

Is this also true for cloud firestore?

Yes it should be the same

Hi there, i was wondering, what should i write if i need to index by two or more fields, also as for querying, can i just use the get collection with the standard appgyver filtering ?

The question might sound silly, but ive been looking everywhere for this, i would appreciate any help on this or even some links of documentation or example where i can find out more about it.
Thanks
image

I am currently implementing this in my app. Assuming you’re using firebase as your backend, my best guess (as right now I am having issues getting multiple single data sources) would be to:

  1. Setup the rules as JOHN_WORSHAM has, but change the values to your data (ie collection, document, the search indexes you want configured, if you have multiple use the same syntax

“.indexOn” : [“Banana”, “Apple”, “Pear”]
)

  1. As John did in step two, configure the formula to be to your endpoint with the appropriate values changed to your setup

"https://YOURENDPOINT/?" + pageVars.Fruit + “/SearchParameter?=” +pageVars.Name

@JOHN_WORSHAM Hi John,

I have tried to duplicate everything, you have mentioned above, however, I am not able to get these data into the paragraph. When I put an alter just behind the HTTP node, I am getting the right list of data but when I push these data into the AppVar and try to show the value in paragraph, I am not getting any further.


I have tried use either VALUES(OUTPUT)[0] or do this for each one of the field, but getting the same result, unfortunately.



Thanks for any advice! :slight_smile:

I have tried to duplicate everything, you have mentioned above, however, I am not able to get these data into the paragraph. When I put an alter just behind the HTTP node, I am getting the right list of data but when I push these data into the AppVar and try to show the value in paragraph, I am not getting any further.

Are you alerting the output, or the variable?

I have alerted the output of HTTP node.

And I am assuming when you alert the variable, its null or undefined?

That’s right, Zach. HTTP node is giving me array, however the appVar is returning null. I have tried to used MAP to display only some values within the array but it seems like the array cannot be stored in Variable for some reason even though format is the same in the HTTP output.

Can you show what works? What are you alerting in the alert right behind the HTTP node, and how does that differ from what you are trying to put into the app variable?

I recommend that you use ENCODE_JSON(appVars.realtime_messaging) in the paragraph, I prefer to debug in that way :slight_smile:

What is the scheme of the variable?

Hi there, i was wondering, does the solution that you write about, have to do with this problem??

Thanks!