database - How to retrieve an Option[List[X]] instead of List[X] from a select statement in Play2!Scala Anorm? -
in play2 app, trying retrieve list of users 1 of database table. query responsible may potentially empty if there no row in database matching criteria (which firstname in our case). why have managed implement :
db.withconnection { implicit connection => sql("""select u.* users u u.firstname '%{firstname}%' """).on("firstname" -> firstname).as(userparser *) }
this query returns list[user] how can return option[list[user]] since query may not retrieve data corresponding provided param (firstname) ?
any appreciated thanks...
you don't need to. if no user found. list empty.
Comments
Post a Comment