All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.getquill.context.qzio.ZioContext.scala Maven / Gradle / Ivy

There is a newer version: 4.8.6
Show newest version
package io.getquill.context.qzio

import io.getquill.NamingStrategy
import io.getquill.context.{ Context, StreamingContext }
import zio.ZIO
import zio.stream.ZStream
import io.getquill.context.ExecutionInfo

trait ZioContext[Idiom <: io.getquill.idiom.Idiom, Naming <: NamingStrategy] extends Context[Idiom, Naming]
  with StreamingContext[Idiom, Naming] {

  type Error
  type Environment

  // It's nice that we don't actually have to import any JDBC libraries to have a Connection type here
  override type StreamResult[T] = ZStream[Environment, Error, T]
  override type Result[T] = ZIO[Environment, Error, T]
  override type RunQueryResult[T] = List[T]
  override type RunQuerySingleResult[T] = T

  // Need explicit return-type annotations due to scala/bug#8356. Otherwise macro system will not understand Result[Long]=Task[Long] etc...
  def executeQuery[T](sql: String, prepare: Prepare = identityPrepare, extractor: Extractor[T] = identityExtractor)(executionInfo: ExecutionInfo, dc: DatasourceContext): ZIO[Environment, Error, List[T]]

  // Query Single is not supported yet
  //def executeQuerySingle[T](sql: String, prepare: Prepare = identityPrepare, extractor: Extractor[T] = identityExtractor): ZIO[Environment, Error, T]
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy