With a JOOQ DSLContext variable ctx I have a method to select all relationship data.
open fun selectAllSomethings(id: String): List<SomeDto> = ctx
.select(..),
.from(..)
.join(..)
.leftJoin(...)
.fetch()
.map()
And I need to reused this logic with an add method where for a concrete id I want to change the code to use fetchOne and map. How can I reuse the first part of query and share it between both methods? This part:
ctx.select(..),
.from(..)
.join(..)
.leftJoin(...)
Is it necessary to divide this into two different methods? Or need to add an if ?