const _ = require('lodash');
const knex = strapi.connections.default;
const result = await knex('restaurants')
.where('cities', 'berlin')
.whereNot('cities.published_at', null)
.join('chefs', 'restaurants.id', 'chefs.restaurant_id')
.select('restaurants.name as restaurant')
.select('chef.name as chef');
// Lodash's groupBy method can be used to
// return a grouped key-value object generated from
// the response
return _.groupBy(result, 'chef');
https://docs-v3.strapi.io/developer-docs/latest/development/backend-customization.html#queries
If we modify Strapi backend and use Knex like in the v3 guide, will it have to be changed again when migrating to v4 from v3?
The migration guide doesn't mention anything about it, but they say that it uses Knex without going through their own custom solution first, so I am guessing it won't be needed to modify anything, but I just wanted to make sure.