{"id":18384863,"url":"https://github.com/allegro/ecto-cursor-based-stream","last_synced_at":"2025-10-29T23:31:47.761Z","repository":{"id":68630832,"uuid":"565986823","full_name":"allegro/ecto-cursor-based-stream","owner":"allegro","description":"Elixir library that allows for cursor-based streaming of Ecto records, that does not require database transaction.","archived":false,"fork":false,"pushed_at":"2024-08-14T08:26:02.000Z","size":47,"stargazers_count":88,"open_issues_count":2,"forks_count":4,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-07T02:11:12.761Z","etag":null,"topics":["ecto","elixir","elixir-lang","hex"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/ecto_cursor_based_stream","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/allegro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-14T18:34:46.000Z","updated_at":"2025-01-30T20:21:26.000Z","dependencies_parsed_at":"2024-05-16T12:30:16.827Z","dependency_job_id":"56be9a99-c5e6-4496-a570-087d32eb09c3","html_url":"https://github.com/allegro/ecto-cursor-based-stream","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fecto-cursor-based-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fecto-cursor-based-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fecto-cursor-based-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allegro%2Fecto-cursor-based-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allegro","download_url":"https://codeload.github.com/allegro/ecto-cursor-based-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238766835,"owners_count":19526919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecto","elixir","elixir-lang","hex"],"created_at":"2024-11-06T01:15:43.470Z","updated_at":"2025-10-29T23:31:40.924Z","avatar_url":"https://github.com/allegro.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EctoCursorBasedStream\n\n![Build Status](https://img.shields.io/github/actions/workflow/status/allegro/ecto-cursor-based-stream/test.yml) [![Hex.pm](https://img.shields.io/hexpm/v/ecto_cursor_based_stream.svg)](https://hex.pm/packages/ecto_cursor_based_stream) [![Documentation](https://img.shields.io/badge/documentation-gray)](https://hexdocs.pm/ecto_cursor_based_stream/)\n\nCursor-based streaming of Ecto records, that does not require database transaction.\n\nGives you a [`cursor_based_stream/2`](https://hexdocs.pm/ecto_cursor_based_stream/EctoCursorBasedStream.html#c:cursor_based_stream/2) function that mimics [`Ecto.Repo.stream/2`](https://hexdocs.pm/ecto/Ecto.Repo.html#c:stream/2) interface.\n\nAdvantages in comparison to the standard `Ecto.Repo.stream/2`:\n\n- streaming can be stopped and continued at any point (by passing option `after_cursor: ...`),\n- works with tables that have milions of records.\n\nOnly limitation is that you have to supply a _cursor column or columns_ (by passing option `cursor_field: ...`, defaults to `:id`). Such a column(s):\n\n- must have unique values,\n- should have a database index. (So that sorting by it, and returning a number of rows larger than `x` is a performant operation.)\n\n## Usage\n\n1. Add `ecto_cursor_based_stream` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:ecto_cursor_based_stream, \"~\u003e 1.2.0\"}\n  ]\nend\n```\n\n2. Add `use EctoCursorBasedStream` to the module that uses `Ecto.Repo`:\n\n```elixir\ndefmodule MyRepo do\n  use Ecto.Repo\n  use EctoCursorBasedStream\nend\n```\n\n3. Stream the rows using `cursor_based_stream/2`:\n\n```elixir\nPost\n|\u003e MyRepo.cursor_based_stream()\n|\u003e Stream.each(...)\n|\u003e Stream.run()\n```\n\n## Useful links\n\n- [Documentation](https://hexdocs.pm/ecto_cursor_based_stream/EctoCursorBasedStream.html)\n- [Examples](https://github.com/allegro/ecto-cursor-based-stream/blob/main/test/ecto_cursor_based_stream_test.exs)\n\n## Contributing\n\n### Running tests\n\nRun the following after cloning the repo:\n\n```sh\nmix deps.get\ndocker-compose up -d\nmix test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallegro%2Fecto-cursor-based-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallegro%2Fecto-cursor-based-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallegro%2Fecto-cursor-based-stream/lists"}