replace raw queries with knex and thenables