PostgreSQL and Exposed - Kotlin database access

Опубликовано: 12 Март 2026
на канале: Pairing with Duncan
8,563
124

Whether or not we pursue our Event Sourcing experiment from the last episode (   • Functional Kotlin - Simple Event Sourcing  ) we know that we want to store our stock data in a database of some sort. So today we investigate using the JetBrains Exposed library (https://github.com/JetBrains/Exposed) to write to and read from PostgreSQL (https://www.postgresql.org/).

Writing tests is a fine way to investigate an API. We can use the tests to invoke functions, and assertions to record what they do, and then work outwards to implement useful and tested code for our application.

After evaluating both, in the end I choose jOOQ over Exposed for our database access. See

jOOQ and PostgreSQL -    • jOOQ and PostgreSQL - Kotlin database acce...  

jOOQ vs Exposed -    • jOOQ vs Exposed - Kotlin database access w...  

This is part 61 of an exploration of where a Test Driven Development implementation of the Gilded Rose stock control system might take us in Kotlin. You can see the whole series as a playlist
   • All Gilded Rose Episodes  
and the code on GitHub
https://github.com/dmcg/gilded-rose-tdd

If you like this, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook
(http://java-to-kotlin.dev). It's about far more than just the syntax differences between the languages - it shows how to upgrade your thinking to a more functional style.

I have some free time between producing videos and working for team Gilded Rose. If you like these videos I'd like to work with you - please get in touch - [email protected]