2022-08-21 10:03:27 +00:00
|
|
|
package dev.inmo.plaguposter.ratings.exposed
|
|
|
|
|
|
|
|
import dev.inmo.micro_utils.repos.KeyValueRepo
|
|
|
|
import dev.inmo.micro_utils.repos.exposed.keyvalue.ExposedKeyValueRepo
|
|
|
|
import dev.inmo.micro_utils.repos.mappers.withMapper
|
|
|
|
import dev.inmo.plaguposter.posts.models.PostId
|
|
|
|
import dev.inmo.plaguposter.ratings.models.Rating
|
|
|
|
import dev.inmo.plaguposter.ratings.repo.RatingsRepo
|
|
|
|
import org.jetbrains.exposed.sql.Column
|
|
|
|
import org.jetbrains.exposed.sql.Database
|
|
|
|
|
|
|
|
class ExposedRatingsRepo(
|
2022-09-04 09:46:45 +00:00
|
|
|
database: Database
|
2022-08-21 10:03:27 +00:00
|
|
|
) : RatingsRepo, KeyValueRepo<PostId, Rating> by ExposedKeyValueRepo(
|
|
|
|
database,
|
2022-09-04 09:46:45 +00:00
|
|
|
{ text("post_id") },
|
2022-08-21 10:03:27 +00:00
|
|
|
{ double("rating") },
|
|
|
|
"ratings"
|
|
|
|
).withMapper(
|
|
|
|
{ string },
|
|
|
|
{ double },
|
|
|
|
{ PostId(this) },
|
|
|
|
{ Rating(this) }
|
|
|
|
)
|