← Back to Stormify Documentation

readCursor

inline fun <T : Any> readCursor(query: String, vararg params: Any?, fetchSize: Int = cursorFetchSize, customFields: Map<String, (Any?) -> Unit>? = null, noinline consumer: (T) -> Unit): Int

Executes a SELECT query and processes results row-by-row via consumer. Returns row count.

Parameters

fetchSize

wire-protocol batch size hint passed to the underlying driver via Statement.setFetchSize. Defaults to cursorFetchSize (the instance-wide default). Set to 0 to opt out of streaming for a single call (drivers fall back to their own default, typically eager). Larger values cut round-trips on high-latency links; smaller values cap per-batch memory. Independent of the in-process FK-batching size used by forEachStreaming (see SiblingGroup.DEFAULT_BATCH_SIZE).

customFields

optional per-column interceptors. Any column whose label matches a key (case-insensitively) is passed to the associated lambda instead of being mapped onto the entity, allowing sidecar aggregates (e.g. COUNT(*) OVER () AS __total) to be captured in a single roundtrip without breaking entity mapping. Ignored for Map and scalar result types since those expose every column to the caller directly.