What is the syntax for filtering a query in Transformer

I think something like this would work, it might need a little tweaking for your specific syntax!

let data = {{formatDataAsArray(query.data)}}
let customer = {{customer_input.value}}.toLowerCase()
let booking = {{booking_input.value}}.toLowerCase()
let statuses = {{status_check_group.value}}

let filtered = data.filter(row=>
    row.customer_name.toLowerCase().includes(customer) 
    && row.booking_id.toLowerCase().startsWith(booking)
    && statuses.includes(row.booking_status)
)

return filtered

A big PSA on this is that loading all of your data into your browser and filtering it down locally with JS in your browser will at a certain size cause some severe performance issues. For small to moderately sized data sets it will be an improvement overall, but definitely something to keep in mind as your database keeps growing. Most web apps will only ever load a single page (i.e. one month of transactions on your banking app). More helpful performance tips here: https://docs.retool.com/docs/building-performant-retool-apps

1 Like