Welcome to another Xano tutorial! Today, we'll explore a powerful feature called "external filtering" that allows you to dynamically assign columns and operators in your custom queries. This comes in handy when you need to filter your data based on user input or changing conditions. Let's dive in!
First, let's create some inputs that will represent the different parts of our filter:
Next, we'll create a variable that will hold our dynamic filter expression. Follow these steps:
Your `filter` variable should now look something like this:
Now that we have our dynamic filter set up, we can use it in our custom query:
That's it! You can now test your dynamic filter by providing different values for the `left`, `operator`, and `right` inputs. For example, if you set `left` to `"userId"`, `operator` to `"="`, and `right` to `"2"`, your query will only return records where the `userId` column is equal to `2`.
But what if you need to filter based on multiple expressions? No problem! Here's how you can do it:
Now, you can filter based on multiple expressions by providing values for all the input fields.
By default, multiple expressions are combined using the `AND` operator. However, you can change this to `OR` by adding the following line to your `filter2` variable:
This way, your query will return records that match either of the provided expressions.
That's it! You now know how to dynamically assign columns and operators in your custom queries using external filtering. This powerful feature opens up a world of possibilities for building flexible and user-friendly applications. Keep exploring and happy coding!
This transcript was AI generated to allow users to quickly answer technical questions about Xano.
I found it helpful
I need more support