I was wondering if anyone new the Wappler way of creating an array from a database query please? I have a query that I want to repeat through and as I make some decisions I then want to add those filtered results into a nested array. I think I can see how I would do that on the front end using https://docs.wappler.io/t/working-with-arrays/7701 however I cannot see anything similar on the backend. I was thinking essentially of an array push function in the server action. Thanks for any help.
Hi @nickneustroev thanks for your reply. I am already using the filter on the DB query before hand. However I am filtering the data further afterwards and I don’t want to perform a second query until I have gathered all the data.
Hi there @datguru… if I understand you correctly, then I would read the initial array into a data store which is held locally, and manipulate the data store elements after that.
I wrote a piece on how to do that a year or so ago… I can’t paste the link here as I’m on my phone, but it is called:
Using a Flow to Fill a Data Store from the Database
Thanks @Antony apologies I should of mentioned that this is server side. Correct me if I’m wrong but I think the data store is app connect / front end?
Maybe just use the where filter for your repeat instead of condition. Then add a setvalue inside the repeat with the data you need. And after that apply the flatten formatter to the repeat, outputting the setvalue in an array.
Example:
We run a query, repeat the query and filter it using the where formatter. Inside the repeat we take the filtered records IDs and then we output it in another setvalue as an array.
Fantastic thanks @Teodor exactly what I was looking for your a star!
Sorry @Teodor one extra question. How do I make a multi dimension associative array in wappler? (please let me know if you would rather this be a new question it feels like it maybe should be!)