knex muliple like query code example
Example: knex muliple like query
public async getFilteredItems(searchCriteria): Promise<any[]> {
const table = 'items';
const columns = ['itemName', 'itemType', 'category'];
const qb = (query) => {
for (const col of columns) {
query.orWhere(`${table}.${col}`, 'like', `%${searchCriteria[col]}%`);
}
}
return await knex(table).where(qb);
}