I have encountered these kind of issues so many times now.
You should not query the model, it doesn’t work, I have no idea why.
What you should do instead, is querying the DB directly.
qb.from("builds_users__users_builds");: what you are doing here is querying a Bookshelf model using Knex syntax
What you could try to do is querying the DB using Knex directly:
const knex = strapi.connections.default;
Then something like
//you should check out knex docs
const res = knex('build')
.join("builds_users__users_builds")
.where("user_id", "user.id");
.andWhere("build_id", "in", function(qb) {
qb.select("id").from("builds")
.whereIn("folder", function(qb) {
qb.select("id")
.from("folders")
.where("project", "project.id");
});
});
I am honestly very disappointed by this ORM
Anyway, this WHERE project = ${project.id} is not the way it should be done. This is subjected to sql injection attacks.
It should be like this ( according to knex’s documentation):
WHERE project = ?" ), project.id)