Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js camelcase 
Javascript :: eachfeature leaflet 
Javascript :: reract native stack yarn 
Javascript :: npm ln 
Javascript :: storybook absolute paths 
Javascript :: javascript expressions JSX 
Javascript :: cheatsheet addeventlistener 
Javascript :: how to clear screen in vis code 
Javascript :: express rate limit redis 
Javascript :: short in javascript 
Javascript :: two dimensional array object in javascript 
Javascript :: sequelize special methods 
Javascript :: open bytes in new tab angular 
Javascript :: create 5 car object using a constructor function in javascript 
Javascript :: return $this-response-withType("application/json")-withStringBody(json_encode($result)); 
Javascript :: javascript get browser is electron 
Javascript :: local = 1 
Javascript :: react enzyme mount ReferenceError: is not defined 
Javascript :: javascript runne 
Javascript :: langenderferc@gmail.com 
Javascript :: elements under p5 canvas 
Javascript :: how to turn a page upside down in javascript 
Javascript :: filter advantages in js 
Javascript :: JS exercise bank account constructor functions and prototypes solution 
Javascript :: Cypress.currentTest 
Javascript :: regular expression arabic and persion 
Javascript :: d3 disable context menu 
Javascript :: KeyEvent event = new KeyEvent(k); event.call(); 
Javascript :: when chrome loads data it resets scroll 
Javascript :: fire off some javascript on page load 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =