I'm slowly porting over a data-layer from slick 2.1 to Slick 3.0.3. I want to keep things syncrhonous for now in order to maintain my repo's API (i.e. no passing back Futures just yet) One thing I need to do is convert methods that look like this:
val query = TableQuery[ContentTable]
def find(id: UUID): Option[ContentModel] = {
getDatabase withSession {
implicit session =>
query.filter(c => c.id === id.toString).firstOption }
}
to read:
def find(id: UUID): Option[ContentModel] = {
Await.result(getDatabase.run(query.filter(c => c.id === id.toString).result.headOption), Duration.Inf) }
However, instead I'd like to do something like:
def find(id: UUID): Option[ContentModel] = {
implict val db = getDatabase
RepoUtils.getOption(query.filter(c => c.id === id.toString)) }
I cannot figure out what the type signatures for a generalized RepoUtils.getOption method would look like. If this is possible, how would the RepoUtils.getOption be formulated?
Thanks,
Craig