scala - Using `firstOption` with slick 3 -


i trying run query .filter(_.id === 1).firstoption compiler complains there no symbol firstoption. removed in slick 3? can use instead?

to limit number of results before calling result, use take(num). example this:

val result: future[option[whatever]] = db.run((query.filter(_.id === 1).take(1)).result).map(_.headoption) 

according official docs, above statement boils down using headoption on result method.

val result: future[option[whatever]] = db.run((query.filter(_.id === 1)).result.headoption) 

query.result returns object of type dbioaction. action in slick can executed on database. actual execution done passing action db.run() or db.stream(). can find more detailed explanation here: http://slick.typesafe.com/doc/3.0.0/api/index.html#slick.dbio.dbioaction


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -