How To Make a Data Table Selector That Uses Workfl...
# 🤝help
n
for example I want to do something like this, get all users with age > X where X is a workflow variable that the users inputs
a
Hey @numerous-parrot-82549, selectors are contstant (so far), but you can use a selector to get all the table's data, and then parse it in code. Here's an example: 1. I have a table of animals, and I make a selector that returns the entire table 2. Then, in code, I write a function to call that selector and then parse through the returned data to find rows that match with the provided data 3. The matches are returned, and then I say the results to the user Here's the code I used:
Copy code
js
const getAnimalsBySize = async (size) => {
  const animals = await AnimalTable.findRecords({ selectorName: 'get_all_animals' })
  const returnArr = animals.filter((animal) => animal.size === size).map((animal) => animal.animal)
  return returnArr
}

workflow.animals = await getAnimalsBySize(event.preview)

https://cdn.discordapp.com/attachments/1142011151874543747/1142050699362959380/image.png

https://cdn.discordapp.com/attachments/1142011151874543747/1142050699664953434/image.png

https://cdn.discordapp.com/attachments/1142011151874543747/1142050700373807194/image.png

n
@acceptable-kangaroo-64719 thanks for your quick response! I am aware of such approach, I just think loading all data an filter on it is not very optimal, but anywy thanks for the advice! appericate it
t
Hey Energizer, I requested this feature in the features request tab. Sounds like we both want the same feature. https://discord.com/channels/1108396290624213082/1142092316216147998/1142092316216147998
39 Views