schemasafe / troy

Type-safe and Schema-safe Scala wrapper for Cassandra driver
Apache License 2.0
151 stars 14 forks source link

Support passing the execution context as param to the query #110

Open tabdulradi opened 7 years ago

tabdulradi commented 7 years ago

The following style needs to be supported

val create = withSchema { (authorId: String, title: String) => implicit ec: ExecutionContext =>
    cql"""
       INSERT INTO test.posts (author_id , post_id , post_title )
       VALUES ( $authorId, now(), $title);
     """.prepared.executeAsync
  }

This should work because we are preparing synchronously, ExecutionContext is needed only on execution of the query, this means it can be passed as param.