ecto-cursor-based-stream icon indicating copy to clipboard operation
ecto-cursor-based-stream copied to clipboard

Feature request: Add support for streaming in descending order

Open Ptrboro opened this issue 1 year ago • 0 comments
trafficstars

Currently, the library only supports streaming records in ascending order. This limitation can be problematic for use cases where descending order is required, such as retrieving the most recent records first.

Proposed enhancement: Add an option to stream records in descending order. This could be implemented by:

  1. Adding a new option to the cursor_based_stream/2 function, e.g., order: :desc (default would remain :asc).
  2. Modifying the query construction logic to support DESC ordering when this option is specified.
  3. Adjusting the cursor generation and comparison logic to work correctly with descending order.

Example usage:

Post
|> MyRepo.cursor_based_stream(order: :desc)

Ptrboro avatar Jul 24 '24 11:07 Ptrboro