Skip to content

Instantly share code, notes, and snippets.

Created August 3, 2017 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d427a50ecd76d463b0b33633a5feef76 to your computer and use it in GitHub Desktop.
Save anonymous/d427a50ecd76d463b0b33633a5feef76 to your computer and use it in GitHub Desktop.
the description for this gist
def categoriesByProducts(productsIds: Seq[ProductId]): Future[Seq[(Seq[ProductId], Category)]] =
db.run(
Taxonometry
.filter(_.productId inSet productsIds)
.join(Categories).on(_.categoryId === _.id)
.result)
.map { result =>
result.groupBy(_._2.id).toVector.map {
case (_, categories) categories.map(_._1.productId) categories.head._2
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment