Method: OccamsRecord::Query#cursor

Defined in:
lib/occams-record/query.rb

#cursor(name: nil, scroll: nil, hold: nil) ⇒ OccamsRecord::Cursor

Returns a cursor you can open and perform operations on. A lower-level alternative to find_each_with_cursor and find_in_batches_with_cursor.

NOTE Postgres only. See the docs for OccamsRecord::Cursor for more details.

Parameters:

  • name (String) (defaults to: nil)

    Specify a name for the cursor (defaults to a random name)

  • scroll (Boolean) (defaults to: nil)

    true = SCROLL, false = NO SCROLL, nil = default behavior of DB

  • hold (Boolean) (defaults to: nil)

    true = WITH HOLD, false = WITHOUT HOLD, nil = default behavior of DB

Returns:



226
227
228
229
230
231
# File 'lib/occams-record/query.rb', line 226

def cursor(name: nil, scroll: nil, hold: nil)
  Cursor.new(model.connection, scope.to_sql,
    name: name, scroll: scroll, hold: hold,
    use: @use, query_logger: @query_logger, eager_loaders: @eager_loaders,
  )
end