Due to change in blocks, Need help for retrieving data from firebase

I have made a project which requires me to search and see if the user input is equal to a value in my database. I’m aware of the similar posts here, however, the answers have different blocks which makes it difficult for me to follow and their data retrieval requirements are different from mine. Any insight would be deeply appreciated. Even the posts from December 2020 have different blocks to what I can find.

This is a simplified version of my actual project :

This is my screen :

This is the database :

  1. I want to take the input from text field and check if that User ID is present in the database. If it is present, I want to change the label that displays “Well…” to “Yes, it matches!”.
  2. I also want to change the label “Does It Match?” to the Name associated with the ID in the database.

Please let me know if you need any other information. I have been trying to figure this out for so long but with no luck. If anyone could explain the concept behind the blocks too, that would be very helpful for me to retrieve the data in other ways as well.

1 Like

What have you tried so far? Show your blocks.

I’ve tried quite a few combinations :

1 Like

When you go in the loop "for each “j” in …, “j” actually has what is under the key “UserID”. But you are using a single “key” just under the “UserID” key and therefore you should check this way

In the loop it should say [for each “j” in list [get object properties of] [cloud variable UserID]
image

if [EID Input text] = [j]

This will get you the correct result.

Correct me if I am wrong but the data is from a firebase database right? So you would need the Realtime DB component.
And welcome to the community!

1 Like

Thank you so much! I’ll try that out.

Yes, but I believe while using cloud variable, Realtime DB component isn’t needed. And thanks for the welcome!

1 Like

To access the data from your database you would need that component

@backscratcher2007 You should not need Realtime DB components and the cloud variable are not only direct but also works in a synchronous mode which eliminates a lot or uncertainty. You also have the listeners readily available for all variables which can monitor any outside changes to the database making it easy to implement multi use capabilities
image
using this block will allow you to know and interact with any change taking place in the database whether from the app or from other sources.

But if @ads_imposters has a private database, how would she use cloud variables to get her data from her database without api and databaseURL?

1 Like

You need to go to project settings page and fill in the API key and Database URL exactly as you would do if you plan to use the components.

In the other hand, the DnD UI does not have the database component and you are left with the cloud variable to interact with Firebase. So better use them from now.

1 Like

oh right, I just checked the documentation on variables.

Yes, its working now! Thank you so much!

If I want to get the name under the UserID, I will have to put another loop under the main loop, like this, correct? :

[for each j ] in list [get properties of ] [cloud variable TestInput]
then, display [j]

2 Likes

If I understand your structure, you can just use the cloud variable format /userid/(user_id_variable_that_you_figured_out)/name

In side the loop do something like this
image

Yes, I can do that using the get property…of object…, Right?

1 Like

Got it, Thank you!

1 Like