Skip to content

Latest commit

 

History

History
14 lines (13 loc) · 337 Bytes

Repo_transaction_exxample.md

File metadata and controls

14 lines (13 loc) · 337 Bytes

Repo Transaction example

  def all_active_accounts(callback) when is_function(callback, 1) do
    Repo.transaction(fn ->
      UserAccount
      |> where([s], is_nil(s.archived_at))
      |> Repo.stream(max_rows: 100)
      |> Stream.chunk_every(100)
      |> Stream.each(callback)
      |> Stream.run()
    end)
  end