queryRecords
queryRecords(
conn,soql,options?):AsyncGenerator<Record<string,string>>
Defined in: packages/simply-core/src/query/queryRecords.ts:123
Run a SOQL query, automatically choosing the REST API or Bulk API v2 based on how many rows it actually returns, and yield the results as a stream of flat, string-valued records regardless of which one was used.
Small queries pay real, fixed latency for a Bulk API v2 job (creation + polling), so this
first runs a cheap SELECT COUNT() version of the query. At or under bulkThreshold
(default 2000, matching the REST API’s page size) it fetches the results via
Connection#autoFetchQuery; above that it streams them via streamBulkQuery, so memory
usage stays flat regardless of result set size.
REST results are flattened to match Bulk’s CSV shape (see flattenRestRecord) and every field is stringified either way, so callers get one consistent record shape no matter which path was taken. Not suitable for Tooling API queries — Bulk API v2 doesn’t support them.
Parameters
Section titled “Parameters”Connection
The org connection to run the query on.
string
The SOQL query to run.
options?
Section titled “options?”QueryRecordsOptions = {}
Optional thresholding/polling behavior overrides.
Returns
Section titled “Returns”AsyncGenerator<Record<string, string>>
Yields
Section titled “Yields”Flat, string-valued records, in query result order.