I'm using slick for my application, and I have 2 tables: table_a and table_b. these two tables have 1->n relationship (n rows of table_b are related to one row of table_a). In the repository layer of my application, I want to perform updates based on the input, and the problem is that I do want to perform updated on table_b in a single query (table_a update is done in a single query before this part), since there can be lots of updates and I don't want to do n queries. Now I have read this question, and found "update-from" (please edit the question and correct me if this has a specific term) query structure pretty useful for my case. I was wondering if Slick has any API to do such thing. I looked up slick documentations and couldn't find the answer.
The SQL statement goes like this:
WITH objects (id, start_date, end_date, entity_id, entity_type) as (
VALUES (1, current_date, current_date, 12, "FOO"),
(2, current_date, current_date, 13, "BAR")
) -- just some mock data, ignore this part
UPDATE table_b tb
set start_date = o.start_date, end_date = o.end_date, entity_id = o.entity_id, entity_type = o.entity_type
FROM objects o where o.id = tb.id;
I can also provide the code, but it probably wouldn't help. And also, I'm trying so hard avoiding raw queries. :D
Thanks in advance!