UPDATE mytable
SET
text = myvalues.mytext,
version = myvalues.myint
FROM (
VALUES
(1, 'textA', 99),
(2, 'textB', 88),
...
) AS myvalues (mykey, mytext, myint)
WHERE mytable.id = myvalues.mykey
I’ve checked the Programming Ecto book, some articles, the docs, but I didn’t find an element and high-performance way to do this.
That’s correct, you’d only be able to use this code to perform updates (which is what you were asking for). You’d have to handle the initial inserts separately.
If you wanted to handle both the initial insert and subsequent updates with a single statement you’d need to provide all of the values to updates = [...] (the var in the example). In that case all of the values would be used for the initial insert but updates would only replace the text and version.