add opportunity to use custom table names in content and post repos for exposed

This commit is contained in:
InsanusMokrassar 2020-08-15 15:23:59 +06:00
parent 13ddb106ad
commit 7d2b1772bb
2 changed files with 10 additions and 6 deletions

View File

@ -22,10 +22,11 @@ private val Content.type
private class ContentRepoDatabaseTable(
private val database: Database,
tableName: String = "",
private val textHolder: ContentHolderRepo<TextContent>,
private val binaryHolder: ContentHolderRepo<BinaryContent>,
private val specialHolder: ContentHolderRepo<SpecialContent>
) : Table("ContentRepo"), ContentRepo, ContentHolderRepo<Content> {
) : Table(tableName), ContentRepo, ContentHolderRepo<Content> {
internal val idColumn = text("_id")
internal val typeColumn = text("type")
@ -147,7 +148,8 @@ private class ContentRepoDatabaseTable(
class ExposedContentRepo (
database: Database,
tableName: String = "",
textHolder: ContentHolderRepo<TextContent> = TextContentHolderRepo(database),
binaryHolder: ContentHolderRepo<BinaryContent> = BinaryContentHolderRepo(database),
specialHolder: ContentHolderRepo<SpecialContent> = SpecialContentHolderRepo(database)
) : ContentRepo by ContentRepoDatabaseTable(database, textHolder, binaryHolder, specialHolder)
) : ContentRepo by ContentRepoDatabaseTable(database, tableName, textHolder, binaryHolder, specialHolder)

View File

@ -71,8 +71,9 @@ private class PostsRepoContentRelations(
private val dateTimeFormat = DateFormat("EEE, dd MMM yyyy HH:mm:ss z")
private class PostsRepoDatabaseTable(
private val database: Database
) : PostsRepo, Table() {
private val database: Database,
tableName: String = ""
) : PostsRepo, Table(tableName) {
private val contentsTable = PostsRepoContentRelations(database)
private val idColumn = text("postId")
@ -210,5 +211,6 @@ private class PostsRepoDatabaseTable(
}
class ExposedPostsRepo (
database: Database
) : PostsRepo by PostsRepoDatabaseTable(database)
database: Database,
tableName: String = ""
) : PostsRepo by PostsRepoDatabaseTable(database, tableName)