Insert if not exists in Slick 3.0.0
It is possible to use a single insert … if not exists query. This avoids multiple database round-trips and race conditions (transactions may not be enough depending on isolation level). def insertIfNotExists(name: String) = users.forceInsertQuery { val exists = (for (u <- users if u.name === name.bind) yield u).exists val insert = (name.bind, None) <> … Read more