Elixir library that allows for cursor-based streaming of Ecto records, that does not require database transaction.
See the codeCursor-based streaming of Ecto records, that does not require database transaction.
Gives you a cursor_based_stream/2 function that mimics Ecto.Repo.stream/2 interface.
Advantages in comparison to the standard Ecto.Repo.stream/2:
after_cursor: ...),Only limitation is that you have to supply a cursor column or columns (by passing option cursor_field: ..., defaults to :id). Such a column(s):
x is a performant operation.)ecto_cursor_based_stream to your list of dependencies in mix.exs:def deps do
[
{:ecto_cursor_based_stream, "~> 1.2.0"}
]
end
use EctoCursorBasedStream to the module that uses Ecto.Repo:defmodule MyRepo do
use Ecto.Repo
use EctoCursorBasedStream
end
cursor_based_stream/2:Post
|> MyRepo.cursor_based_stream()
|> Stream.each(...)
|> Stream.run()
Run the following after cloning the repo:
mix deps.get
docker-compose up -d
mix test
Elixir
100.0%
Elixir library that allows for cursor-based streaming of Ecto records, that does not require database transaction.
See the codeCursor-based streaming of Ecto records, that does not require database transaction.
Gives you a cursor_based_stream/2 function that mimics Ecto.Repo.stream/2 interface.
Advantages in comparison to the standard Ecto.Repo.stream/2:
after_cursor: ...),Only limitation is that you have to supply a cursor column or columns (by passing option cursor_field: ..., defaults to :id). Such a column(s):
x is a performant operation.)ecto_cursor_based_stream to your list of dependencies in mix.exs:def deps do
[
{:ecto_cursor_based_stream, "~> 1.2.0"}
]
end
use EctoCursorBasedStream to the module that uses Ecto.Repo:defmodule MyRepo do
use Ecto.Repo
use EctoCursorBasedStream
end
cursor_based_stream/2:Post
|> MyRepo.cursor_based_stream()
|> Stream.each(...)
|> Stream.run()
Run the following after cloning the repo:
mix deps.get
docker-compose up -d
mix test
Elixir
100.0%