MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / stream

Method stream

packages/mongodb/src/MongoDriver.ts:52–87  ·  view source on GitHub ↗
(
    entityName: EntityName<T>,
    where: FilterQuery<T>,
    options: StreamOptions<T, any, any, any> & { rawResults?: boolean },
  )

Source from the content-addressed store, hash-verified

50 }
51
52 async *stream<T extends object>(
53 entityName: EntityName<T>,
54 where: FilterQuery<T>,
55 options: StreamOptions<T, any, any, any> & { rawResults?: boolean },
56 ): AsyncIterableIterator<T> {
57 if (this.metadata.find(entityName)?.virtual) {
58 yield* this.streamVirtual(entityName, where, options) as any;
59 return;
60 }
61
62 const fields = this.buildFields(
63 entityName,
64 (options.populate as unknown as PopulateOptions<T>[]) || [],
65 options.fields,
66 options.exclude as any,
67 );
68 where = this.renameFields(entityName, where as T, true);
69 const orderBy = Utils.asArray(options.orderBy).map(orderBy => this.renameFields(entityName, orderBy as T, true));
70 const res = this.getConnection('read').stream(entityName, where, {
71 orderBy,
72 limit: options.limit,
73 offset: options.offset,
74 fields,
75 ctx: options.ctx,
76 chunkSize: options.chunkSize ?? 100,
77 ...this.buildQueryOptions(options),
78 });
79
80 for await (const item of res) {
81 if (options.rawResults) {
82 yield item as any;
83 } else {
84 yield this.mapResult(item, this.metadata.find(entityName)) as T;
85 }
86 }
87 }
88
89 async find<T extends object, P extends string = never, F extends string = never, E extends string = never>(
90 entityName: EntityName<T>,

Callers

nothing calls this directly

Calls 10

streamVirtualMethod · 0.95
buildFieldsMethod · 0.95
renameFieldsMethod · 0.95
buildQueryOptionsMethod · 0.95
asArrayMethod · 0.80
findMethod · 0.65
streamMethod · 0.65
getConnectionMethod · 0.65
mapResultMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected