https://kotlinlang.org logo
p

Philipp Mayer

09/18/2019, 7:40 PM
Hey guys, I'm quite new to exposed and pretty sure I'm missing something:
Copy code
override fun getColorByCompany(company: String): List<String> {
        val color = transaction { Companies
                .slice(Companies.color)
                .select { Companies.name eq company }
                .map { it.toString() }
        }
       return color
    }
How can I get a single string as result and not a list of strings? Or should I convert it afterwards for myself? Thanks in advance!
e

Evan R.

09/18/2019, 7:49 PM
I generally use
.firstOrNull()
here. That way you’ll get a string if it exists or null if no results were returned.
p

Philipp Mayer

09/18/2019, 7:53 PM
That solved it. Thanks!
👍 1