Hello everyone, I am currently working on a full-...
# getting-started
Hello everyone, I am currently working on a full-stack web app using the tutorial found here: https://kotlinlang.org/docs/multiplatform-full-stack-app.html#include-kmongo-in-the-process. We have been using MongoDB and KMongo, but I am trying to replace MongoDB with Postgres DB and Kmongo with Exposed. As an example, using Kmongo, we have this code: val client = KMongo.createClient().coroutine val database = client.getDatabase("shoppingList") val collection = database.getCollection<ShoppingListItem>() get { call.respond(collection.find().toList()) } I am wondering if there is a way to do the same thing with Exposed. My current understanding is to create an object DatabaseFactory for setup in Server.kt, create a Table and then use select:
object DatabaseFactory {
fun init() {
driver = "org.postgresql.Driver",
user = "user",
password = "password"
object ShoppingListItems: Table() {
val id = integer("id").autoIncrement().primaryKey()
val name = varchar("name", length = 255)
val owners = varchar("owners", length = 255)
get {
call.respond(ShoppingListItems.select { ShoppingListItems.owners like user }.toList())
I am also wondering if we need to create a table. Instead, I want to use a data class like this: val collection = database.getCollection<ShoppingListItem>(). Thank you in advance for your help!
Hi! I'm not familiar with Exposed, but you'll likely get better answers by asking in #exposed. Good luck!
Thanks for the reply! I have actually waited for the reply in #exposed, but it seems like no one is active. And I decided to post in getting-started. I have also posted in #ktor too, so hopefully someone responds!