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

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -