Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Refactor WorkshopRepository list method
Browse files Browse the repository at this point in the history
The commit changes the implementation of the list method in the WorkshopRepository class. Instead of using a transaction block, it now uses the dbQuery helper from the DatabaseFactory. It also updates the method to be suspending, which is more suitable for the usage of dbQuery.
  • Loading branch information
daudmohamed committed Apr 6, 2024
1 parent 3fbdc73 commit 4d7bf9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions backend/app/src/main/kotlin/backend/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fun Application.module() {
).init()
configureAuth()
configureRouting()

}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backend.repository

import backend.dto.WorkshopDTO
import com.inventy.plugins.DatabaseFactory.Companion.dbQuery
import kotlinx.serialization.Contextual
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.ResultRow
Expand Down Expand Up @@ -37,10 +38,8 @@ class WorkshopRepository {
it[capacity]
)
}
fun list(): List<Workshop> {
return transaction {
WorkshopTable.selectAll()
.map(WorkshopTable::toModel)
}
suspend fun list(): List<Workshop> = dbQuery {
WorkshopTable.selectAll()
.map(WorkshopTable::toModel)
}
}

0 comments on commit 4d7bf9b

Please sign in to comment.