📜  knex muliple like query - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:11.448000             🧑  作者: Mango

代码示例1
public async getFilteredItems(searchCriteria): Promise {
    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);
}