Closed AdamVig closed 7 years ago
This is easy to fix in services/filter-query.js
, but difficult to fix in all of the individual controllers that supply knex.modify()
functions.
The reason it is difficult is because the flow looks like this:
(req, queryBuilder) => { ... }
)req
as the first parameter to the modify functionknex.modify(modifyFunction)
, expecting the function to accept queryBuilder
as its first parameter (which it does, after req
is bound in the endpoint service)The fix would look like:
queryBuilder, req
req
into the db service so it could call the modify function like knex.modify(modifyFunction, req)
The problem with this is that it increases the coupling between the endpoint service and the db service, a problem that will be solved in #373 Refactor endpoint service. Once the endpoint service is refactored to not pass parameters through to the db service, each controller can directly pass req
to the db service so that modify()
can be used correctly.
./services/filter-query.js
,./controllers/model.js
, and./services/endpoint.js
use Knex's modify function incorrectly. See the documentation.Instead of returning functions (in
filter-query.js
) and binding parameters (inendpoint.js
), just callmodify
with a function as its first parameter, and the other parameters will be passed to the function.