Advertisement
Guest User

Untitled

a guest
Mar 18th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.63 KB | None | 0 0
  1. private val PARSER = long("id")~str("email")~str("password_hash")~
  2.                          bool("locked")~date("created_on")~date("last_login") map {
  3.     case a~b~c~d~e~f => User(a, b, c, d, new DateTime(e), new DateTime(f), PaymentProcessor.fetchBlocking(a))
  4.   }
  5.  
  6.  
  7.   private val FETCH_BY_ID = "SELECT * FROM users WHERE `id` = {id}"
  8.   def fetch(id: Long): Future[Option[User]] = Future { fetchBlocking(id) }
  9.   def fetchBlocking(id: Long): Option[User] = DB.withConnection(c => fetchBlockingC(id)(c))
  10.   def fetchBlockingC(id: Long)(implicit c: Connection): Option[User] =
  11.     SQL(FETCH_BY_ID).on('id -> id).as(PARSER *).headOption
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement