Is there any library that makes you build SQL queries in the same way as you modify a list?
Example
personsDbTable.all
.filter { it.age < 30 }
.sortedBy { it.age }
.slice(5..10)
.toSql()
Produces
SELECT *
FROM persons
WHERE age < 30
ORDER BY age
LIMIT 5
OFFSET 5
Example 2
personsDbTable.all
.map { it.age }
.max()
.toSql()
Produces
SELECT MAX(age)
FROM persons
Not sure yet how to handle joins, or if this can be handled with such a library. What do you think?
Is there anything like this out there? If not, would it be useful?