對一些從多個位置拉出來的數據運行Squeryl調用,但由於某種原因它會作爲一個單位返回。我如何讓它作爲Iterable返回?爲什麼Scala查詢返回單位?
下面是拉的數據:
/**
* gets a stream for a particular user
*/
def getUserStream(userId:Long) {
User.teamIds(userId).toList.map((team) =>
Stream.findByTeam(team,0,5).map((stream) =>
List(stream)
).flatten
).flatten.sortBy(_.id)
}
然後輸出數據,其中返回結果爲Unit
:
Stream.getUserStream(userId) match {
case results => {
Ok(generate(results.map((stream) => Map(
"id" -> stream.id,
"model" -> stream.model,
"time" -> stream.time,
"content" -> stream.content
))
)).as("application/json")
}
case _ => Ok("")
}
我最初的猜測是一個函數可以返回爲無,但它不會只是返回一個空的列表?
可能重複的[何時使用等號在Scala的方法聲明登錄?](http://stackoverflow.com/questions/944111/when-to-use-the-equals-sign- in-a-scala-method-declaration) – 2012-04-09 04:37:15