(
entityName: EntityName<T>,
pipeline: any[],
ctx?: Transaction<ClientSession>,
loggerContext?: LoggingOptions,
signal?: AbortSignal,
)
| 328 | } |
| 329 | |
| 330 | async aggregate<T extends object = any>( |
| 331 | entityName: EntityName<T>, |
| 332 | pipeline: any[], |
| 333 | ctx?: Transaction<ClientSession>, |
| 334 | loggerContext?: LoggingOptions, |
| 335 | signal?: AbortSignal, |
| 336 | ): Promise<T[]> { |
| 337 | await this.ensureConnection(); |
| 338 | const collection = this.getCollectionName(entityName); |
| 339 | /* v8 ignore next */ |
| 340 | const options: Dictionary = ctx ? { session: ctx } : {}; |
| 341 | if (signal) { |
| 342 | options.signal = signal; |
| 343 | } |
| 344 | const query = `db.getCollection('${collection}').aggregate(${this.logObject(pipeline)}, ${this.logObject(options)}).toArray();`; |
| 345 | const now = Date.now(); |
| 346 | const res = await this.getCollection(entityName).aggregate<T>(pipeline, options).toArray(); |
| 347 | this.logQuery(query, { took: Date.now() - now, results: res.length, ...loggerContext }); |
| 348 | |
| 349 | return res; |
| 350 | } |
| 351 | |
| 352 | async *streamAggregate<T extends object>( |
| 353 | entityName: EntityName<T>, |
nothing calls this directly
no test coverage detected