io.getquill.context
Use to provide run(myQuery) calls with a context implicitly saving the need to provide things multiple times.
run(myQuery)
Use to provide run(myQuery) calls with a context implicitly saving the need to provide things multiple times. For example in JDBC:
case class MyQueryService(ds: DataSource) { import Ctx._ implicit val env = Implicit(Has(ds)) val joes = Ctx.run(query[Person].filter(p => p.name == "Joe")).implicitly val jills = Ctx.run(query[Person].filter(p => p.name == "Jill")).implicitly val alexes = Ctx.run(query[Person].filter(p => p.name == "Alex")).implicitly }
Normally you would have to do a separate provide for each clause:
provide
val joes = Ctx.run(query[Person].filter(p => p.name == "Joe")).provide(Has(ds)) val jills = Ctx.run(query[Person].filter(p => p.name == "Jill")).provide(Has(ds)) val alexes = Ctx.run(query[Person].filter(p => p.name == "Alex")).provide(Has(ds))
For other contexts e.g. Cassandra the functionality is identical.
case class MyQueryService(cs: CassandraZioSession) { import Ctx._ implicit val env = Implicit(Has(cs)) def joes = Ctx.run { query[Person].filter(p => p.name == "Joe") }.implicitly def jills = Ctx.run { query[Person].filter(p => p.name == "Jill") }.implicitly def alexes = Ctx.run { query[Person].filter(p => p.name == "Alex") }.implicitly }
Use to provide
run(myQuery)
calls with a context implicitly saving the need to provide things multiple times. For example in JDBC:Normally you would have to do a separate
provide
for each clause:For other contexts e.g. Cassandra the functionality is identical.