Answers for "knex muliple like query"

0

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);
}
Posted by: Guest on April-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language