@mikro-orm/mongodb 7.0.0-dev.1 → 7.0.0-dev.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,12 @@
1
- import { MongoClient, type ClientSession, type Collection, type Db, type MongoClientOptions, type TransactionOptions } from 'mongodb';
2
- import { Connection, type AnyEntity, type Configuration, type ConnectionOptions, type ConnectionType, type EntityData, type EntityName, type FilterQuery, type IsolationLevel, type QueryOrderMap, type QueryResult, type Transaction, type TransactionEventBroadcaster, type UpsertOptions, type UpsertManyOptions, type LoggingOptions } from '@mikro-orm/core';
1
+ import { type ClientSession, type Collection, type Db, MongoClient, type MongoClientOptions, type TransactionOptions } from 'mongodb';
2
+ import { type AnyEntity, type Configuration, Connection, type ConnectionOptions, type ConnectionType, type EntityData, type EntityName, type FilterQuery, type IsolationLevel, type LoggingOptions, type QueryOrderMap, type QueryResult, type Transaction, type TransactionEventBroadcaster, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';
3
3
  export declare class MongoConnection extends Connection {
4
- protected client: MongoClient;
5
- protected db: Db;
4
+ #private;
6
5
  constructor(config: Configuration, options?: ConnectionOptions, type?: ConnectionType);
7
- connect(): Promise<void>;
6
+ connect(options?: {
7
+ skipOnConnect?: boolean;
8
+ }): Promise<void>;
9
+ createClient(): void;
8
10
  close(force?: boolean): Promise<void>;
9
11
  isConnected(): Promise<boolean>;
10
12
  checkConnection(): Promise<{
@@ -20,16 +22,18 @@ export declare class MongoConnection extends Connection {
20
22
  listCollections(): Promise<string[]>;
21
23
  dropCollection(name: EntityName<AnyEntity>): Promise<boolean>;
22
24
  mapOptions(overrides: MongoClientOptions): MongoClientOptions;
23
- getClientUrl(): string;
24
25
  getDb(): Db;
25
26
  execute(query: string): Promise<any>;
26
27
  find<T extends object>(collection: string, where: FilterQuery<T>, orderBy?: QueryOrderMap<T> | QueryOrderMap<T>[], limit?: number, offset?: number, fields?: string[], ctx?: Transaction<ClientSession>, loggerContext?: LoggingOptions): Promise<EntityData<T>[]>;
28
+ stream<T extends object>(collection: string, where: FilterQuery<T>, orderBy?: QueryOrderMap<T> | QueryOrderMap<T>[], limit?: number, offset?: number, fields?: string[], ctx?: Transaction<ClientSession>, loggerContext?: LoggingOptions): AsyncIterableIterator<T>;
29
+ private _find;
27
30
  insertOne<T extends object>(collection: string, data: Partial<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult<T>>;
28
31
  insertMany<T extends object>(collection: string, data: Partial<T>[], ctx?: Transaction<ClientSession>): Promise<QueryResult<T>>;
29
32
  updateMany<T extends object>(collection: string, where: FilterQuery<T>, data: Partial<T>, ctx?: Transaction<ClientSession>, upsert?: boolean, upsertOptions?: UpsertOptions<T>): Promise<QueryResult<T>>;
30
33
  bulkUpdateMany<T extends object>(collection: string, where: FilterQuery<T>[], data: Partial<T>[], ctx?: Transaction<ClientSession>, upsert?: boolean, upsertOptions?: UpsertManyOptions<T>): Promise<QueryResult<T>>;
31
34
  deleteMany<T extends object>(collection: string, where: FilterQuery<T>, ctx?: Transaction<ClientSession>): Promise<QueryResult<T>>;
32
35
  aggregate<T extends object = any>(collection: string, pipeline: any[], ctx?: Transaction<ClientSession>, loggerContext?: LoggingOptions): Promise<T[]>;
36
+ streamAggregate<T extends object>(collection: string, pipeline: any[], ctx?: Transaction<ClientSession>, loggerContext?: LoggingOptions, stream?: boolean): AsyncIterableIterator<T>;
33
37
  countDocuments<T extends object>(collection: string, where: FilterQuery<T>, ctx?: Transaction<ClientSession>): Promise<number>;
34
38
  transactional<T>(cb: (trx: Transaction<ClientSession>) => Promise<T>, options?: {
35
39
  isolationLevel?: IsolationLevel;
@@ -1,53 +1,54 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MongoConnection = void 0;
4
- const mongodb_1 = require("mongodb");
5
- const bson_1 = require("bson");
6
- const node_util_1 = require("node:util");
7
- const core_1 = require("@mikro-orm/core");
8
- class MongoConnection extends core_1.Connection {
9
- client;
10
- db;
1
+ import { MongoClient, ObjectId, } from 'mongodb';
2
+ import { Connection, EventType, QueryOrder, Utils, ValidationError, inspect, } from '@mikro-orm/core';
3
+ export class MongoConnection extends Connection {
4
+ #client;
5
+ #db;
11
6
  constructor(config, options, type = 'write') {
12
7
  super(config, options, type);
13
8
  // @ts-ignore
14
- bson_1.ObjectId.prototype[node_util_1.inspect.custom] = function () {
9
+ ObjectId.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
15
10
  return `ObjectId('${this.toHexString()}')`;
16
11
  };
17
12
  // @ts-ignore
18
- Date.prototype[node_util_1.inspect.custom] = function () {
13
+ Date.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
19
14
  return `ISODate('${this.toISOString()}')`;
20
15
  };
21
16
  }
22
- async connect() {
17
+ async connect(options) {
18
+ this.getClient();
19
+ this.connected = true;
20
+ if (options?.skipOnConnect !== true) {
21
+ await this.onConnect();
22
+ }
23
+ }
24
+ createClient() {
23
25
  let driverOptions = this.options.driverOptions ?? this.config.get('driverOptions');
24
26
  if (typeof driverOptions === 'function') {
25
- driverOptions = await driverOptions();
27
+ driverOptions = driverOptions();
26
28
  }
27
- if (driverOptions instanceof mongodb_1.MongoClient) {
29
+ if (driverOptions instanceof MongoClient) {
28
30
  this.logger.log('info', 'Reusing MongoClient provided via `driverOptions`');
29
- this.client = driverOptions;
31
+ this.#client = driverOptions;
30
32
  }
31
33
  else {
32
- this.client = new mongodb_1.MongoClient(this.config.getClientUrl(), this.mapOptions(driverOptions));
33
- await this.client.connect();
34
+ this.#client = new MongoClient(this.config.get('clientUrl'), this.mapOptions(driverOptions));
34
35
  const onCreateConnection = this.options.onCreateConnection ?? this.config.get('onCreateConnection');
35
- /* istanbul ignore next */
36
- this.client.on('connectionCreated', () => {
37
- void onCreateConnection?.(this.client);
36
+ /* v8 ignore next */
37
+ this.#client.on('connectionCreated', () => {
38
+ void onCreateConnection?.(this.#client);
38
39
  });
39
40
  }
40
- this.db = this.client.db(this.config.get('dbName'));
41
- this.connected = true;
41
+ this.#db = this.#client.db(this.config.get('dbName'));
42
42
  }
43
43
  async close(force) {
44
- await this.client?.close(!!force);
44
+ await this.#client?.close(force);
45
45
  this.connected = false;
46
+ this.#client = undefined;
46
47
  }
47
48
  async isConnected() {
48
49
  try {
49
- const res = await this.db?.command({ ping: 1 });
50
- return this.connected = !!res.ok;
50
+ const res = await this.#db?.command({ ping: 1 });
51
+ return this.connected = !!res?.ok;
51
52
  }
52
53
  catch (error) {
53
54
  return this.connected = false;
@@ -55,8 +56,8 @@ class MongoConnection extends core_1.Connection {
55
56
  }
56
57
  async checkConnection() {
57
58
  try {
58
- const res = await this.db?.command({ ping: 1 });
59
- return res.ok
59
+ const res = await this.#db?.command({ ping: 1 });
60
+ return res?.ok
60
61
  ? { ok: true }
61
62
  : { ok: false, reason: 'Ping reply does not feature "ok" property, or it evaluates to "false"' };
62
63
  }
@@ -65,20 +66,23 @@ class MongoConnection extends core_1.Connection {
65
66
  }
66
67
  }
67
68
  getClient() {
68
- return this.client;
69
+ if (!this.#client) {
70
+ this.createClient();
71
+ }
72
+ return this.#client;
69
73
  }
70
74
  getCollection(name) {
71
- return this.db.collection(this.getCollectionName(name));
75
+ return this.getDb().collection(this.getCollectionName(name));
72
76
  }
73
77
  async createCollection(name) {
74
- return this.db.createCollection(this.getCollectionName(name));
78
+ return this.getDb().createCollection(this.getCollectionName(name));
75
79
  }
76
80
  async listCollections() {
77
- const collections = await this.db.listCollections({}, { nameOnly: true }).toArray();
81
+ const collections = await this.getDb().listCollections({}, { nameOnly: true }).toArray();
78
82
  return collections.map(c => c.name);
79
83
  }
80
84
  async dropCollection(name) {
81
- return this.db.dropCollection(this.getCollectionName(name));
85
+ return this.getDb().dropCollection(this.getCollectionName(name));
82
86
  }
83
87
  mapOptions(overrides) {
84
88
  const ret = {};
@@ -86,36 +90,40 @@ class MongoConnection extends core_1.Connection {
86
90
  const username = this.config.get('user');
87
91
  const password = this.config.get('password');
88
92
  if (this.config.get('host')) {
89
- throw new core_1.ValidationError('Mongo driver does not support `host` options, use `clientUrl` instead!');
93
+ throw new ValidationError('Mongo driver does not support `host` options, use `clientUrl` instead!');
90
94
  }
91
95
  if (username && password) {
92
96
  ret.auth = { username, password };
93
97
  }
94
- if (pool.min) {
95
- ret.minPoolSize = pool.min;
96
- }
97
- if (pool.max) {
98
- ret.maxPoolSize = pool.max;
99
- }
98
+ ret.minPoolSize = pool.min;
99
+ ret.maxPoolSize = pool.max;
100
+ ret.waitQueueTimeoutMS = pool.idleTimeoutMillis;
100
101
  ret.driverInfo = {
101
102
  name: 'MikroORM',
102
- version: core_1.Utils.getORMVersion(),
103
+ version: Utils.getORMVersion(),
103
104
  };
104
- return core_1.Utils.mergeConfig(ret, overrides);
105
- }
106
- getClientUrl() {
107
- const options = this.mapOptions(this.options.driverOptions ?? {});
108
- const clientUrl = this.config.getClientUrl(true);
109
- const match = clientUrl.match(/^(\w+):\/\/((.*@.+)|.+)$/);
110
- return match ? `${match[1]}://${options.auth ? options.auth.username + ':*****@' : ''}${match[2]}` : clientUrl;
105
+ return Utils.mergeConfig(ret, overrides);
111
106
  }
112
107
  getDb() {
113
- return this.db;
108
+ this.#db ??= this.getClient().db(this.config.get('dbName'));
109
+ return this.#db;
114
110
  }
115
111
  async execute(query) {
116
112
  throw new Error(`${this.constructor.name} does not support generic execute method`);
117
113
  }
118
114
  async find(collection, where, orderBy, limit, offset, fields, ctx, loggerContext) {
115
+ const { cursor, query } = await this._find(collection, where, orderBy, limit, offset, fields, ctx, loggerContext);
116
+ const now = Date.now();
117
+ const res = await cursor.toArray();
118
+ this.logQuery(`${query}.toArray();`, { took: Date.now() - now, results: res.length, ...loggerContext });
119
+ return res;
120
+ }
121
+ async *stream(collection, where, orderBy, limit, offset, fields, ctx, loggerContext) {
122
+ const { cursor, query } = await this._find(collection, where, orderBy, limit, offset, fields, ctx, loggerContext);
123
+ this.logQuery(`${query}.toArray();`, loggerContext);
124
+ yield* cursor;
125
+ }
126
+ async _find(collection, where, orderBy, limit, offset, fields, ctx, loggerContext) {
119
127
  await this.ensureConnection();
120
128
  collection = this.getCollectionName(collection);
121
129
  const options = ctx ? { session: ctx } : {};
@@ -124,18 +132,17 @@ class MongoConnection extends core_1.Connection {
124
132
  }
125
133
  const resultSet = this.getCollection(collection).find(where, options);
126
134
  let query = `db.getCollection('${collection}').find(${this.logObject(where)}, ${this.logObject(options)})`;
127
- orderBy = core_1.Utils.asArray(orderBy);
135
+ orderBy = Utils.asArray(orderBy);
128
136
  if (Array.isArray(orderBy) && orderBy.length > 0) {
129
137
  const orderByTuples = [];
130
138
  orderBy.forEach(o => {
131
- core_1.Utils.keys(o).forEach(k => {
139
+ Utils.keys(o).forEach(k => {
132
140
  const direction = o[k];
133
- orderByTuples.push([k.toString(), core_1.Utils.isString(direction) ? direction.toUpperCase() === core_1.QueryOrder.ASC ? 1 : -1 : direction]);
141
+ orderByTuples.push([k.toString(), typeof direction === 'string' ? direction.toUpperCase() === QueryOrder.ASC ? 1 : -1 : direction]);
134
142
  });
135
143
  });
136
144
  if (orderByTuples.length > 0) {
137
145
  query += `.sort(${this.logObject(orderByTuples)})`;
138
- // @ts-expect-error ??
139
146
  resultSet.sort(orderByTuples);
140
147
  }
141
148
  }
@@ -147,10 +154,7 @@ class MongoConnection extends core_1.Connection {
147
154
  query += `.skip(${offset})`;
148
155
  resultSet.skip(offset);
149
156
  }
150
- const now = Date.now();
151
- const res = await resultSet.toArray();
152
- this.logQuery(`${query}.toArray();`, { took: Date.now() - now, results: res.length, ...loggerContext });
153
- return res;
157
+ return { cursor: resultSet, query };
154
158
  }
155
159
  async insertOne(collection, data, ctx) {
156
160
  return this.runQuery('insertOne', collection, data, undefined, ctx);
@@ -170,7 +174,7 @@ class MongoConnection extends core_1.Connection {
170
174
  async aggregate(collection, pipeline, ctx, loggerContext) {
171
175
  await this.ensureConnection();
172
176
  collection = this.getCollectionName(collection);
173
- /* istanbul ignore next */
177
+ /* v8 ignore next */
174
178
  const options = ctx ? { session: ctx } : {};
175
179
  const query = `db.getCollection('${collection}').aggregate(${this.logObject(pipeline)}, ${this.logObject(options)}).toArray();`;
176
180
  const now = Date.now();
@@ -178,6 +182,16 @@ class MongoConnection extends core_1.Connection {
178
182
  this.logQuery(query, { took: Date.now() - now, results: res.length, ...loggerContext });
179
183
  return res;
180
184
  }
185
+ async *streamAggregate(collection, pipeline, ctx, loggerContext, stream = false) {
186
+ await this.ensureConnection();
187
+ collection = this.getCollectionName(collection);
188
+ /* v8 ignore next */
189
+ const options = ctx ? { session: ctx } : {};
190
+ const query = `db.getCollection('${collection}').aggregate(${this.logObject(pipeline)}, ${this.logObject(options)})};`;
191
+ const cursor = this.getCollection(collection).aggregate(pipeline, options);
192
+ this.logQuery(query, { ...loggerContext });
193
+ yield* cursor;
194
+ }
181
195
  async countDocuments(collection, where, ctx) {
182
196
  return this.runQuery('countDocuments', collection, undefined, where, ctx);
183
197
  }
@@ -201,27 +215,27 @@ class MongoConnection extends core_1.Connection {
201
215
  await this.ensureConnection();
202
216
  const { ctx, isolationLevel, eventBroadcaster, ...txOptions } = options;
203
217
  if (!ctx) {
204
- await eventBroadcaster?.dispatchEvent(core_1.EventType.beforeTransactionStart);
218
+ await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionStart);
205
219
  }
206
- const session = ctx || this.client.startSession();
220
+ const session = ctx || this.getClient().startSession();
207
221
  session.startTransaction(txOptions);
208
222
  this.logQuery('db.begin();');
209
- await eventBroadcaster?.dispatchEvent(core_1.EventType.afterTransactionStart, session);
223
+ await eventBroadcaster?.dispatchEvent(EventType.afterTransactionStart, session);
210
224
  return session;
211
225
  }
212
226
  async commit(ctx, eventBroadcaster) {
213
227
  await this.ensureConnection();
214
- await eventBroadcaster?.dispatchEvent(core_1.EventType.beforeTransactionCommit, ctx);
228
+ await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionCommit, ctx);
215
229
  await ctx.commitTransaction();
216
230
  this.logQuery('db.commit();');
217
- await eventBroadcaster?.dispatchEvent(core_1.EventType.afterTransactionCommit, ctx);
231
+ await eventBroadcaster?.dispatchEvent(EventType.afterTransactionCommit, ctx);
218
232
  }
219
233
  async rollback(ctx, eventBroadcaster) {
220
234
  await this.ensureConnection();
221
- await eventBroadcaster?.dispatchEvent(core_1.EventType.beforeTransactionRollback, ctx);
235
+ await eventBroadcaster?.dispatchEvent(EventType.beforeTransactionRollback, ctx);
222
236
  await ctx.abortTransaction();
223
237
  this.logQuery('db.rollback();');
224
- await eventBroadcaster?.dispatchEvent(core_1.EventType.afterTransactionRollback, ctx);
238
+ await eventBroadcaster?.dispatchEvent(EventType.afterTransactionRollback, ctx);
225
239
  }
226
240
  async runQuery(method, collection, data, where, ctx, upsert, upsertOptions, loggerContext) {
227
241
  await this.ensureConnection();
@@ -257,10 +271,10 @@ class MongoConnection extends core_1.Connection {
257
271
  const bulk = this.getCollection(collection).initializeUnorderedBulkOp(options);
258
272
  data.forEach((row, idx) => {
259
273
  const id = where[idx];
260
- const cond = core_1.Utils.isPlainObject(id) ? id : { _id: id };
274
+ const cond = Utils.isPlainObject(id) ? id : { _id: id };
261
275
  const doc = this.createUpdatePayload(row, upsertOptions);
262
276
  if (upsert) {
263
- if (core_1.Utils.isEmpty(cond)) {
277
+ if (Utils.isEmpty(cond)) {
264
278
  query += log(() => `bulk.insert(${this.logObject(row)});\n`);
265
279
  bulk.insert(row);
266
280
  }
@@ -299,12 +313,19 @@ class MongoConnection extends core_1.Connection {
299
313
  createUpdatePayload(row, upsertOptions) {
300
314
  const doc = { $set: row };
301
315
  const $unset = {};
302
- core_1.Utils.keys(row)
303
- .filter(k => typeof row[k] === 'undefined')
304
- .forEach(k => {
305
- $unset[k] = '';
306
- delete row[k];
307
- });
316
+ const $inc = {};
317
+ for (const k of Utils.keys(row)) {
318
+ const item = row[k];
319
+ if (typeof item === 'undefined') {
320
+ $unset[k] = '';
321
+ delete row[k];
322
+ continue;
323
+ }
324
+ if (Utils.isPlainObject(item) && '$inc' in item) {
325
+ $inc[k] = item.$inc;
326
+ delete row[k];
327
+ }
328
+ }
308
329
  if (upsertOptions) {
309
330
  if (upsertOptions.onConflictAction === 'ignore') {
310
331
  doc.$setOnInsert = doc.$set;
@@ -328,11 +349,14 @@ class MongoConnection extends core_1.Connection {
328
349
  });
329
350
  }
330
351
  }
331
- if (core_1.Utils.hasObjectKeys($unset)) {
352
+ if (Utils.hasObjectKeys($unset)) {
332
353
  doc.$unset = $unset;
333
- if (!core_1.Utils.hasObjectKeys(doc.$set)) {
334
- delete doc.$set;
335
- }
354
+ }
355
+ if (Utils.hasObjectKeys($inc)) {
356
+ doc.$inc = $inc;
357
+ }
358
+ if (!Utils.hasObjectKeys(doc.$set)) {
359
+ delete doc.$set;
336
360
  }
337
361
  return doc;
338
362
  }
@@ -344,7 +368,7 @@ class MongoConnection extends core_1.Connection {
344
368
  };
345
369
  }
346
370
  getCollectionName(name) {
347
- name = core_1.Utils.className(name);
371
+ name = Utils.className(name);
348
372
  const meta = this.metadata.find(name);
349
373
  return meta ? meta.collection : name;
350
374
  }
@@ -352,7 +376,6 @@ class MongoConnection extends core_1.Connection {
352
376
  if (o.session) {
353
377
  o = { ...o, session: `[ClientSession]` };
354
378
  }
355
- return (0, node_util_1.inspect)(o, { depth: 5, compact: true, breakLength: 300 });
379
+ return inspect(o, { depth: 5, compact: true, breakLength: 300 });
356
380
  }
357
381
  }
358
- exports.MongoConnection = MongoConnection;
package/MongoDriver.d.ts CHANGED
@@ -1,17 +1,22 @@
1
- import type { ClientSession } from 'mongodb';
2
- import { type Configuration, type CountOptions, DatabaseDriver, type EntityData, type EntityDictionary, type EntityField, EntityManagerType, type FilterQuery, type FindOneOptions, type FindOptions, type IDatabaseDriver, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type PopulateOptions, type PopulatePath, type QueryResult, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';
3
- import { MongoConnection } from './MongoConnection';
4
- import { MongoPlatform } from './MongoPlatform';
5
- import { MongoEntityManager } from './MongoEntityManager';
1
+ import { type ClientSession } from 'mongodb';
2
+ import { type Configuration, type Constructor, type CountOptions, DatabaseDriver, type EntityData, type EntityDictionary, type EntityField, EntityManagerType, type EntityName, type FilterQuery, type FindOneOptions, type FindOptions, type NativeInsertUpdateManyOptions, type NativeInsertUpdateOptions, type PopulateOptions, type PopulatePath, type QueryResult, type StreamOptions, type Transaction, type UpsertManyOptions, type UpsertOptions } from '@mikro-orm/core';
3
+ import { MongoConnection } from './MongoConnection.js';
4
+ import { MongoPlatform } from './MongoPlatform.js';
5
+ import { MongoEntityManager } from './MongoEntityManager.js';
6
+ import { MongoMikroORM } from './MongoMikroORM.js';
6
7
  export declare class MongoDriver extends DatabaseDriver<MongoConnection> {
7
8
  [EntityManagerType]: MongoEntityManager<this>;
8
9
  protected readonly connection: MongoConnection;
9
10
  protected readonly platform: MongoPlatform;
10
11
  constructor(config: Configuration);
11
- createEntityManager<D extends IDatabaseDriver = IDatabaseDriver>(useContext?: boolean): D[typeof EntityManagerType];
12
+ createEntityManager(useContext?: boolean): this[typeof EntityManagerType];
13
+ stream<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: StreamOptions<T, any, any, any> & {
14
+ rawResults?: boolean;
15
+ }): AsyncIterableIterator<T>;
12
16
  find<T extends object, P extends string = never, F extends string = '*', E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOptions<T, P, F, E>): Promise<EntityData<T>[]>;
13
17
  findOne<T extends object, P extends string = never, F extends string = PopulatePath.ALL, E extends string = never>(entityName: string, where: FilterQuery<T>, options?: FindOneOptions<T, P, F, E>): Promise<EntityData<T> | null>;
14
18
  findVirtual<T extends object>(entityName: string, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): Promise<EntityData<T>[]>;
19
+ streamVirtual<T extends object>(entityName: EntityName<T>, where: FilterQuery<T>, options: FindOptions<T, any, any, any>): AsyncIterableIterator<EntityData<T>>;
15
20
  count<T extends object>(entityName: string, where: FilterQuery<T>, options?: CountOptions<T>, ctx?: Transaction<ClientSession>): Promise<number>;
16
21
  nativeInsert<T extends object>(entityName: string, data: EntityDictionary<T>, options?: NativeInsertUpdateOptions<T>): Promise<QueryResult<T>>;
17
22
  nativeInsertMany<T extends object>(entityName: string, data: EntityDictionary<T>[], options?: NativeInsertUpdateManyOptions<T>): Promise<QueryResult<T>>;
@@ -21,9 +26,13 @@ export declare class MongoDriver extends DatabaseDriver<MongoConnection> {
21
26
  ctx?: Transaction<ClientSession>;
22
27
  }): Promise<QueryResult<T>>;
23
28
  aggregate(entityName: string, pipeline: any[], ctx?: Transaction<ClientSession>): Promise<any[]>;
29
+ streamAggregate<T extends object>(entityName: string, pipeline: any[], ctx?: Transaction<ClientSession>): AsyncIterableIterator<T>;
24
30
  getPlatform(): MongoPlatform;
25
31
  private renameFields;
26
32
  private convertObjectIds;
27
33
  private buildFilterById;
28
34
  protected buildFields<T extends object, P extends string = never>(entityName: string, populate: PopulateOptions<T>[], fields?: readonly EntityField<T, P>[], exclude?: string[]): string[] | undefined;
35
+ private handleVersionProperty;
36
+ /** @inheritDoc */
37
+ getORMClass(): Constructor<MongoMikroORM>;
29
38
  }