Skip to content

Commit

Permalink
extract context
Browse files Browse the repository at this point in the history
  • Loading branch information
andrzejjozwik committed Sep 6, 2019
1 parent 71a01b3 commit aa00f12
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
Expand Up @@ -16,18 +16,24 @@ object AsyncJdbcRepository {

trait AsyncJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection]
extends AsyncRepositoryWithGeneratedId[K, T]
with WithUpdate[Long] {
protected val context: AsyncJdbcContextDateQuotes[D, N, C]
with WithUpdate[Long]
with WithAsyncJdbcContext[D, N, C] {

protected def dynamicSchema: context.DynamicEntityQuery[T]
}

trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection] extends AsyncRepository[K, T] with WithUpdate[Long] {
protected val context: AsyncJdbcContextDateQuotes[D, N, C]
trait AsyncJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection]
extends AsyncRepository[K, T]
with WithUpdate[Long]
with WithAsyncJdbcContext[D, N, C] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

}

trait AsyncJdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy, C <: Connection]
extends AsyncJdbcRepository[K, T, D, N, C]

trait WithAsyncJdbcContext[D <: SqlIdiom, N <: NamingStrategy, C <: Connection] {
protected val context: AsyncJdbcContextDateQuotes[D, N, C]
}
Expand Up @@ -11,11 +11,14 @@ object CassandraAsyncRepository {
type CassandraAsyncContextDateQuotes[N <: NamingStrategy] = CassandraAsyncContext[N] with AsyncCrudWithContextDateQuotesUnit
}

trait CassandraAsyncRepository[K, T <: WithId[K], N <: NamingStrategy] extends AsyncRepository[K, T] with WithUpdate[Unit] {
protected val context: CassandraAsyncContextDateQuotes[N]
trait CassandraAsyncRepository[K, T <: WithId[K], N <: NamingStrategy] extends AsyncRepository[K, T] with WithUpdate[Unit] with WithCassandraAsyncContext[N] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

}

trait CassandraAsyncRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraAsyncRepository[K, T, N]

trait WithCassandraAsyncContext[N <: NamingStrategy] {
protected val context: CassandraAsyncContextDateQuotes[N]
}
Expand Up @@ -10,11 +10,12 @@ object CassandraRepository {
type CassandraContextDateQuotes[N <: NamingStrategy] = CassandraSyncContext[N] with CrudWithContextDateQuotesUnit
}

trait CassandraRepository[K, T <: WithId[K], N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Unit] {
protected val context: CassandraContextDateQuotes[N]
trait CassandraRepository[K, T <: WithId[K], N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Unit] with WithCassandraContext[N] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

}

trait CassandraRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraRepository[K, T, N]

trait WithCassandraContext[N <: NamingStrategy] { protected val context: CassandraContextDateQuotes[N] }
Expand Up @@ -10,11 +10,12 @@ object CassandraMonixRepository {
type CassandraMonixContextDateQuotes[N <: NamingStrategy] = CassandraMonixContext[N] with MonixWithContextDateQuotesUnit
}

trait CassandraMonixRepository[K, T <: WithId[K], N <: NamingStrategy] extends MonixRepository[K, T] with WithUpdate[Unit] {
protected val context: CassandraMonixContextDateQuotes[N]

trait CassandraMonixRepository[K, T <: WithId[K], N <: NamingStrategy] extends MonixRepository[K, T] with WithUpdate[Unit] with WithCassandraMonixContext[N] {
protected def dynamicSchema: context.DynamicEntityQuery[T]

}

trait CassandraMonixRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], N <: NamingStrategy] extends CassandraMonixRepository[K, T, N]

trait WithCassandraMonixContext[N <: NamingStrategy] {
protected val context: CassandraMonixContextDateQuotes[N]
}
Expand Up @@ -13,17 +13,18 @@ object JdbcRepository {
type JdbcContextDateQuotes[D <: SqlIdiom, N <: NamingStrategy] = JdbcContext[D, N] with ContextDateQuotes[D, N]
}

trait JdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends SyncRepositoryWithGeneratedId[K, T] with WithUpdate[Long] {
protected val context: JdbcContextDateQuotes[D, N]
trait JdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy]
extends SyncRepositoryWithGeneratedId[K, T]
with WithUpdate[Long]
with WithJdbcContext[D, N] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

def inTransaction[A](task: A): A =
context.transaction(task)
}

trait JdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Long] {
protected val context: JdbcContextDateQuotes[D, N]
trait JdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends SyncRepository[K, T] with WithUpdate[Long] with WithJdbcContext[D, N] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

Expand All @@ -33,3 +34,7 @@ trait JdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] exte
}

trait JdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends JdbcRepository[K, T, D, N]

trait WithJdbcContext[D <: SqlIdiom, N <: NamingStrategy] {
protected val context: JdbcContextDateQuotes[D, N]
}
Expand Up @@ -13,8 +13,10 @@ object MonixJdbcRepository {
type MonixJdbcContextDateQuotes[D <: SqlIdiom, N <: NamingStrategy] = MonixJdbcContext[D, N] with MonixWithContextDateQuotesLong
}

trait MonixJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends MonixRepository[K, T] with WithUpdate[Long] {
protected val context: MonixJdbcContextDateQuotes[D, N]
trait MonixJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy]
extends MonixRepository[K, T]
with WithUpdate[Long]
with WithMonixJdbcContext[D, N] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

Expand All @@ -25,14 +27,17 @@ trait MonixJdbcRepository[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy]

trait MonixJdbcRepositoryWithGeneratedId[K, T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy]
extends MonixRepositoryWithGeneratedId[K, T]
with WithUpdate[Long] {

protected val context: MonixJdbcContextDateQuotes[D, N]
with WithUpdate[Long]
with WithMonixJdbcContext[D, N] {

protected def dynamicSchema: context.DynamicEntityQuery[T]

def inTransaction[A](task: Task[A]): Task[A] =
context.transaction(task)
}

trait WithMonixJdbcContext[D <: SqlIdiom, N <: NamingStrategy] {
protected val context: MonixJdbcContextDateQuotes[D, N]
}

trait MonixJdbcRepositoryCompositeKey[K <: CompositeKey[_, _], T <: WithId[K], D <: SqlIdiom, N <: NamingStrategy] extends MonixJdbcRepository[K, T, D, N]
2 changes: 1 addition & 1 deletion version.sbt
@@ -1 +1 @@
ThisBuild / version := "0.8.5"
ThisBuild / version := "0.8.6"

0 comments on commit aa00f12

Please sign in to comment.