Seeking ways to create an API that allows admins to search for users in the database using various fields.
// Define allowed search fields
type SearchFieldType = 'name' | 'memberNo' | 'email' | 'companyName';
const dbColumns = ['username', 'member_no', 'email', 'company_name'] as const;
Admins can input one or multiple search fields when making requests through the API.
How can I determine which field is provided in the API request and search the corresponding column in the database without relying on if-else statements due to potential future expansions of columns?