Nic
Nic4d ago

Searching two columns

Trying to find a way to search by two columns, with pagination. withSearchIndex works, when we look for one column but I need to search inside 2 columns. Do I really need to pull the whole table, then filter the data? Have a search box, and it needs to pull from users table a result for their name and/or email.
5 Replies
Convex Bot
Convex Bot4d ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Nic
NicOP4d ago
Typically, the LIKE "%" would do great here with normal RDBS something that lets us concat 2 columns into one index would be beneficial too
lee
lee4d ago
To concat columns you can do this https://stack.convex.dev/triggers#denormalizing-a-field or you can do the equivalent of LIKE % in an RDBMS which is to read all the data and filter
Database Triggers
Triggers automatically run code whenever data in a table changes. A library in the convex-helpers npm package allows you to attach trigger functions t...
AlphaOmega
AlphaOmega4d ago
A computed values helper defined when defining the table ( much like indexes ) would be so much better. Triggers do work but it also seems like too much hassle for such a simple concept
Nic
NicOP4d ago
yeah, trigger seems like the way to go to build a computed column/index. In fact i need to do a deep dive on triggers to see where i can add it into my codebase thanks! for now ill just do a read all/filter, as the tables going to be < few thousand documents

Did you find this page helpful?