2017-06-17 5 views
0

私はSlickとScalaには本当に新しく、IDのリストでクエリをフィルタリングすることで悩んでいます。IDリストでTableQueryをフィルタリングする方法は?

productsNeededIds // = "1,2,3,4,5" - list of Ids of products 

質問:分割リストからすべてのIDを使用してクエリを取得するには、どのように.filterを使用できますか?お使いの製品のIDが文字列であると仮定しています

def productsWithIds(productsNeededIds: String)(implicit ec: ExecutionContext): Future[List[ProductsREST]] = { 

var splitedSet :Set[String] = productsNeededIds.split(",").toSet 
val query = Products.filter(_.prodId.inSet(splitedSet)) 

def productsWithIds(productsNeededIds: String)(implicit ec: ExecutionContext): Future[List[ProductsREST]] = { 

    var splitedArray :Array[String] = productsNeededIds.split(",") 
    val query = Products.filter(_.prodId === splitedArray)// what should be here instead of ===splitedArray? 
} 

答えて

1

あなたはinSetメソッドを使用する必要があります。代わりにIntの場合は、最初にsplittedSetIntにマッピングする必要があります。

関連する問題