luckyframework/avram

Support for CURSOR

開放

#1,008 建立於 2024年3月6日

 (0 則留言) (0 個反應) (0 位負責人)Crystal (67 個分叉)auto 404
feature requesthacktoberfest

倉庫指標

星標
 (180 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

A CURSOR would allow us to paginate really large collections.

I've never implemented or even really used these directly, but I found this example

-- We must be in a transaction
BEGIN;
-- Open a cursor for a query
DECLARE medley_cur CURSOR FOR SELECT * FROM medley;
-- Retrieve ten rows
FETCH 10 FROM medley_cur;
-- ...
-- Retrieve ten more from where we left off
FETCH 10 FROM medley_cur;
-- All done
COMMIT;

I honestly have no clue how this will work, but I think we would probably want some alternate method of iterating that appends the cursor to the query?

UserQuery.new.each_with_cursor(fetch: 10) do |user|
  #??
end

UserQuery.new.cursor_fetch(10).each do |user|

end

If anyone has any ideas around this, I'm open.

貢獻者指南