How to wrap multiple bulk updates in transaction
I have a list of maps that I want to use in a bulk update in my database.
The list looks something like this:
I want to update my DB rows accordingly to set the
So I thought to use
However, I want to wrap them in a transaction. Is that possible and if so, how?
The list looks something like this:
I want to update my DB rows accordingly to set the
exposed field to true or false for every ID in the list. I don't know if this is possible to do in a single query. It may be with a huge CASE expression in the query, but that's besides the point and probably overkill.So I thought to use
Enum.split_with/2 to split the list into two lists: one for IDs to expose and one for IDs to hide. Then I can run two bulk updates.However, I want to wrap them in a transaction. Is that possible and if so, how?
