Non sono un utente Knex.js, ma guardando i documenti sembra che l'uso da parte di Knex della sintassi degli oggetti JavaScript per definire i predicati sia il modo in cui ottiene la parametrizzazione.
Tuttavia, poiché stai utilizzando le funzioni integrate, devi utilizzare whereRaw .
Guardando i documenti ( https://knexjs.org/#Builder-whereRaw ) e ( https://knexjs.org/#Raw-Bindings ) Penso che tu voglia farlo:
.whereRaw('question LIKE :term OR note LIKE :term OR user_name LIKE :term', { term: '%' + term + '%' ] } )
Knex non ha un orWhereRaw , quindi dovresti usare la versione a mano lunga se vuoi separare logicamente i predicati:
term = '%' + term + '%';
.orWhere( knex.raw( 'question LIKE ?', [ term ] ) )
.orWhere( knex.raw( 'note LIKE ?', [ term ] ) )
.orWhere( knex.raw( 'user_name LIKE ?', [ term ] ) )
Nota ? è per i parametri posizionali e :term è per parametri denominati.