Search code examples
mysqlbookshelf.jsknex.js

perform a query with mysql function like now() in bookshelf.js


in Knex.js/bookshelf.js how do i do the following

select * from `events` where end_time >= now() 

Passing now in a where() causes it to be taken as a parameter and not as a function

 qb.andWhere("end_time", ">=", "now()");

Solution

  • Not sure in bookshelf, but taken it uses Knex directly, I'd say you should try:

    qb.andWhere("end_time", ">=", knex.fn.now());