Skip to main content
Version: Next

StreamOptions <Entity, Populate, Fields, Exclude>

Options for streaming query results via em.stream().

Hierarchy

  • Omit<FindAllOptions<Entity, Populate, Fields, Exclude>, cache | before | after | first | last | overfetch | strategy>
    • StreamOptions

Index

Properties

optionalinheritedallowDiskUse

allowDiskUse?: boolean

mongodb only

optionalchunkSize

chunkSize?: number = 100 (on dialects that honor it)

How many rows to fetch in one round-trip. Lower values will result in more queries and network bandwidth, but less memory usage. Higher values will result in fewer queries and network bandwidth, but higher memory usage. Note that the results are iterated one row at a time regardless of this value.

Honored on PostgreSQL (cursor-based fetch), MSSQL (tedious stream chunk size), Oracle (mapped to fetchArraySize) and MongoDB (mapped to batchSize). Ignored on MySQL, MariaDB, SQLite and libSQL, where the underlying driver already streams row-by-row with no batching knob.

optionalinheritedcollation

collation?: string | CollationOptions

SQL: collation name string applied as COLLATE to ORDER BY; MongoDB: CollationOptions object.

optionalinheritedcomments

comments?: string | string[]

sql only

optionalinheritedconnectionType

connectionType?: ConnectionType

optionalinheritedconvertCustomTypes

convertCustomTypes?: boolean

optionalinheritedctx

ctx?: any

optionalinheriteddisableIdentityMap

disableIdentityMap?: boolean

optionalinheritedexclude

exclude?: readonly AutoPath<Entity, Exclude, never, 9>[]

optionalinheritedfields

fields?: readonly AutoPath<Entity, Fields, *, 9>[]

optionalinheritedfilters

filters?: FilterOptions

optionalinheritedflags

flags?: QueryFlag[]

optionalinheritedflushMode

flushMode?: always | FlushMode | commit | auto

optionalinheritedgroupBy

groupBy?: string | string[]

sql only

optionalinheritedhaving

having?: FilterQuery<Entity>

optionalinheritedhintComments

hintComments?: string | string[]

sql only

optionalinheritedindexHint

indexHint?: string | Dictionary

SQL: appended to FROM clause (e.g. 'force index(my_index)'); MongoDB: index name or spec passed as hint.

optionalinheritedinflightQueryAbortStrategy

inflightQueryAbortStrategy?: InflightQueryAbortStrategy

Strategy used when the signal fires while the query is in flight. See InflightQueryAbortStrategy for caveats around streams and MongoDB.

optionalinheritedlimit

limit?: number

Limit the number of returned results. If you try to use limit/offset on a query that joins a to-many relation, pagination mechanism will be triggered, resulting in a subquery condition, to apply this limit only to the root entities instead of the cartesian product you get from a database in this case.

optionalinheritedlockMode

lockMode?: NONE | PESSIMISTIC_READ | PESSIMISTIC_WRITE | PESSIMISTIC_PARTIAL_WRITE | PESSIMISTIC_WRITE_OR_FAIL | PESSIMISTIC_PARTIAL_READ | PESSIMISTIC_READ_OR_FAIL

sql only

optionalinheritedlockTableAliases

lockTableAliases?: string[]

sql only

optionalinheritedloggerContext

loggerContext?: LogContext

optionalinheritedlogging

logging?: LoggingOptions

optionalinheritedmaxTimeMS

maxTimeMS?: number

mongodb only

optionalmergeResults

mergeResults?: boolean = true

When populating to-many relations, the ORM streams fully merged entities instead of yielding every row. You can opt out of this behavior by specifying mergeResults: false. This will yield every row from the SQL result, but still mapped to entities, meaning that to-many collections will contain at most a single item, and you will get duplicate root entities when they have multiple items in the populated collection.

optionalinheritedoffset

offset?: number

Sets the offset. If you try to use limit/offset on a query that joins a to-many relation, pagination mechanism will be triggered, resulting in a subquery condition, to apply this limit only to the root entities instead of the cartesian product you get from a database in this case.

optionalinheritedorderBy

orderBy?: OrderDefinition<Entity>

Ordering of the results.Can be an object or array of objects, keys are property names, values are ordering (asc/desc)

optionalinheritedpopulate

populate?: Populate<Entity, Populate>

optionalinheritedpopulateFilter

populateFilter?: ObjectQuery<Entity>

Filter condition for populated relations. This is similar to populateWhere, but will produce a left join when nesting the condition. This is used for implementation of joined filters.

optionalinheritedpopulateHints

populateHints?: [Populate] extends [never] ? never : { [ K in string ]?: PopulateHintOptions }

Per-relation overrides for populate loading behavior. Keys are populate paths (same as used in populate).

optionalinheritedpopulateOrderBy

populateOrderBy?: OrderDefinition<Entity>

Used for ordering of the populate queries. If not specified, the value of options.orderBy is used.

optionalinheritedpopulateWhere

populateWhere?: PopulateHint | infer | all | ObjectQuery<Entity>

Where condition for populated relations. This will have no effect on the root entity. With select-in strategy, this is applied only to the populate queries. With joined strategy, those are applied as join on conditions. When you use a nested condition on a to-many relation, it will produce a nested inner join, discarding the collection items based on the child condition.

optionalinheritedrefresh

refresh?: boolean

optionalinheritedschema

schema?: string

optionalinheritedsignal

signal?: AbortSignal

AbortSignal that cancels the query when fired.

optionalinheritedunionWhere

unionWhere?: ObjectQuery<Entity>[]

Index-friendly alternative to $or for conditions that span joined relations. Each array element becomes an independent branch combined via UNION ALL subquery: WHERE pk IN (branch_1 UNION ALL branch_2 ... branch_N). The database plans each branch independently, enabling per-table index usage (e.g. GIN trigram indexes for fuzzy search across related entities). sql only

optionalinheritedunionWhereStrategy

unionWhereStrategy?: union-all | union

Strategy for combining unionWhere branches.

  • 'union-all' (default) — skips deduplication, faster for most use cases.
  • 'union' — deduplicates rows between branches; useful when branch overlap is very high. sql only

optionalinheritedusing

using?: IndexName<Entity> | IndexName<Entity>[]

Named index(es) for this query. When provided:

  • Validates that where and orderBy only reference columns covered by the specified index(es).
  • Emits SQL index hints where supported (MySQL/MariaDB: USE INDEX, MSSQL: WITH (INDEX(...))).
  • If indexHint is also set, indexHint takes precedence for SQL generation.

Accepts a single index name or an array. For defineEntity entities with named indexes and decorator entities with [IndexHints], index names are autocompleted.

@example
await em.find(Book, { title: 'foo' }, { using: 'idx_book_title' });
await em.find(Book, { title: 'foo', author: 1 }, { using: ['idx_book_title', 'idx_book_author'] });

optionalinheritedwhere

where?: FilterQuery<Entity>