knex muliple like query

Solutions on MaxInterview for knex muliple like query by the best coders in the world

showing results for - "knex muliple like query"
Martina
22 Jan 2016
1public async getFilteredItems(searchCriteria): Promise<any[]> {
2    const table = 'items';
3    const columns = ['itemName', 'itemType', 'category'];
4    const qb = (query) => {
5      for (const col of columns) {
6        query.orWhere(`${table}.${col}`, 'like', `%${searchCriteria[col]}%`);
7      }
8    }
9    return await knex(table).where(qb);
10}