Hello there! In this guide, we'll walk through how to use the powerful filtering capabilities in Xano to fetch conversations based on the members (users) involved. This can be incredibly useful for building features like group chats, collaboration tools, or any application that involves multiple users interacting within a shared context.
Let's get started!
First things first, navigate to the Conversations table in your Xano project. This is where we'll be performing our filtering operation.
The Conversations table likely has a column that stores an array of references to the members (users) involved in each conversation. In our example, this column is called members.
contains OperatorXano provides a handy operator called contains that allows us to filter arrays based on exact matches. This is perfect for our use case!
To use the contains operator, follow these steps:
members column.contains operator from the list of available options.For example, if you want to fetch all conversations that involve users with IDs 1, 3, and 5, you can enter 1, 3, 5 in the input field.
After entering your desired member IDs, you'll see the table update in real-time, displaying only the conversations that match your filter criteria.
Here's an example of what the filtered results might look like:
ID | members
2 | [1, 3, 5, 7]
3 | [1, 3, 5]
In this case, we filtered for conversations involving users 1, 3, and 5, and the table returned two conversations (IDs 2 and 3) that match that criteria.
contains Operator vs. the in OperatorIt's worth noting that the contains operator differs from the in operator in its behavior. The in operator will match any array that contains at least one of the values in your input, while contains is more strict and will only match arrays that contain all the specified values.
For example, if you use in with the input 1, 3, 5, it might return conversations with member arrays like [1, 2, 3], [4, 5], or [1, 3, 5, 6]. On the other hand, contains with the same input will only return conversations with the exact member array [1, 3, 5].
By leveraging the powerful filtering capabilities of Xano, you can easily fetch conversations based on the members involved. The contains operator is a straightforward and efficient way to achieve this, allowing you to build collaborative features and enhance the user experience of your application.
Remember, Xano empowers you to build powerful backend services without writing a single line of code, making it an invaluable tool for developers and non-technical users alike.
Happy building!
Join 100,000+ people already building with Xano.
Start today and scale to millions.
Start building for free