...

/

Functions for Data Access

Functions for Data Access

Learn how to implement functions to manipulate data and carry out main service.

Loading a product

Press + to interact
override def loadProduct(id: ProductId) =
sql"""SELECT products.id, names.lang_code, names.name
FROM products
JOIN names ON products.id = names.product_id
WHERE products.id = $id"""
.query[(ProductId, LanguageCode, ProductName)]
.to[Seq]
.transact(tx)

The loadProduct function simply returns all rows for a single product from the database, exactly like its ...

Access this course and 1400+ top-rated courses and projects.