Firebase Filter Conditions in data variable

I am working on a database app, and I have one big database with much information. I managed to filter my data using this code:

I have no idea why, but if I make a search field, and bind the value to a page variable, the same filter does not work:

Is this a bug, or what am I missing?

Best wishes,

Can anybode please help me? Im stuck at this problem, and I would reallly like to solve it.

Hi Michael, i am encountering the same issue…

Hey user7, please tell me when you have solved this problem!

Hi @Michael_Leitzenberge, what is happening here is:

  1. Page variable is “”
  2. Data collection gets fetched with condition id == “”
  3. Search input changes to “example” → Page var changes to “example”
  4. There is no logic in place to re-fetch the data with id == “example”

To refresh the data when the page var changes, add a “Receive event” node for “Page variable changed” on the data variable’s logic canvas. I also recommend using “Debounce” from the flow function marketplace in between the event and “Get record collection” nodes to prevent sending unnecessarily many queries to the database.

Another way to implement search that just requires one database query is to pull all records from the DB and do the filtering client-side, like outlined in this tutorial: Power-up: Search bar with sugggestions - AppGyver

Thank you so much for your anwser! Does this also work with a firebase database? The database I want so search is a firestore database.

What do you mean with “data variable’s logic”? Do you mean the logic for the page with my search button?

I am a bit confused, because I never used “get record collection”, i just used the data configurator in the DATA section.

Again, thank you for your help, have a nice day!

Here you seem to have a data variable called chemicalsdatabase1, you can find the logic for how it fetches the data by opening the logic canvas at the bottom of the screen:

Perfect, it works now! Yeah, thank you SO much!

I have one last question: if there is only one result of the search, is it possible to get the id of this record without user interaction? For now, I repeat a container with my data variable. By clicking on (one of the/the only) result(s), I can store the id and get a single record using this id.

What i want: The user searches for a specific unique entry, and if there is only one result, the id of this result is stored without any interaction.

Best wishes,

Hi @Michael_Leitzenberge – yes, you could add a page variable to hold the identifier.

Then after the “Set data variable” node on the data variable logic canvas, you can use an “If condition” node with condition formula COUNT(data.chemicalsdatabase1 === 1) (check if the result only has 1 record).

Then if this is true (1st output triggers), you can “Set page variable” to data.chemicalsdatabase1[0].id or however you’ll get the id :slight_smile: