How to filter/sort values on Firebase

Again with more and more doubts… :tired_face::tired_face::tired_face::tired_face:

My app and Firebase are working properly, and now I want the app to “filter” data from Firebase, more especifically from column BOX. So, if I say that I want to see box 1, I want the app to look in my database and only display those cells to me.

The structure of the DB is:

In Thunkable I tried several ways, but none of them work… See my attempts below:

First attempt:
Capturar3

Second attempt:
Capturar5

Thank you once again!

Well the first example looks good to me except for one problem. You are starting the list number at 1 when your database starts at 0

image
image

Is the variable app sizeDB a number, and in a blue block?

Can you also setup a label for the error?

Hi, Cian!

Thank you for your reply. I changed the starting number of the list to 0 (my mistake!) and this variable “sizeDB” is a number I add manually in the global variable. I didn’t know how to code to return the size of my DB and this way I solved my problem temporarily.

Working with localDB was perfect for me, except that I couldn’t update the value. I changed my whole app to work with firebase, but now I struggle with simple things like filtering it.

The first exemple, when I want the app to store a VALUE if VALUE=0, it returns an empty list. But if I remove the IF statement (my filter), and ask the app to build the list, it runs perfectly and returns all items I have there.

r1
(Don’t know why, but I have to ask the app to wait 1 second otherwise it returns repetitive itens)

Then if I ask it to display the error message, it crashes. No matter where the error is put (inside/outside the IF statement)
r2

The error bug is strange.

With the first issue…

Are you setting that as an empty list at the begiing? How do you declare this value?

I declare as an empty list.
rq

Yesterday I also struggled the entire day to put a IF statement inside a “Call from database” statement. It only works without IF. This is why I tried to write a query in the KEY. The proble is that I don’t know how to write… I think it should be something like:

const rootRef = firebase.database(https://myvocab-30705.firebaseio.com/).ref();

rootRef.child(‘Box’).orderByChild(‘Box’).equalTo(‘0’);

This info I got based on this video below:

My app is in Thunkable
If you click the button TRIAL, you will see that it crashes

And by the way, thanks for trying to help me :slight_smile:

Ok there are clearly some bugs.

You cant send the SQL type query through a key string I dont think. It was not designed or formatted for it.

https://firebase.google.com/docs/reference/rest/database/

You can use Firebase REST API found :arrow_up:

You can use these blocks here :arrow_down:

image

2 Likes

Wow, you are being so nice to me. Thank you for taking your time.

I am happy to know the problem is the BUG, and not ME! :rofl::rofl::rofl::rofl:
As I’m a beginner and this is my very first app, I can never tell one problem from another.

Let me learn how to use this API-thing and see if I can use it.

Thank you :heart_eyes::kissing_heart:

The Web function will give lots of flexibility. Its not perfect, and in X there is still lots of room to grow.

Classic gives more certainty, however you dont have the iOS option.

Let me know if there are issues with how to use the API functions.

@IWendling I feel I can help you, but I’d like to understand what do you want to display exactly

This should be the solution you need, the last comments should be what you want to do