I'm trying to update to Slick 3.0.0 (reactive Slick), however I can't get the most basic stuff to work. Before I could just do something like db.withTransaction { ... }
and it would run, however I can't even get this to compile:
def insertNewFacebookUser(
facebookId: String,
email: String,
firstName: String,
lastName: String
) = {
val user =
(Users.map(u ⇒ (u.email, u.firstName, u.lastName)) returning Users) +=
((email, firstName, lastName))
FacebookAuths.map(f ⇒ (f.userId, f.facebookId)) += ((user.id, facebookId))
user
}
This just complains that user.id
is wrapped in some DBIOAction
, how should I write this so it compiles?
Thanks
Without knowing more about the schema:
I'm not sure what the exact type of DBIOAction will be returned as it depends on your schema, hence the
???
. Everything is wrapped in an action of sorts so when you attempt to use theuserId
directly in the insert to FacebookAuths, it's the wrong type. Instead what you want to do ismap
/flatMap
on the returned results and compose your fuller action. Thefor {...} yield
is just sugar onmap
andflatMap
. You thenrun
your action to get aFuture
of your result. You can thenmap
on that as you need to.