@tmlmobilidade/interfaces 20250922.953.29 → 20250924.1552.9

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.
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export * from './src/interfaces/index.js';
3
3
  export * from './src/mongo-collection.js';
4
4
  export * from './src/mongo-transaction.js';
5
5
  export * from './src/providers/index.js';
6
- export type { Collection, DeleteOptions, Document, Filter, FindOptions, IndexDescription, InsertOneOptions, InsertOneResult, MongoClientOptions, OptionalUnlessRequiredId, Sort, UpdateOptions, UpdateResult, WithId, } from 'mongodb';
6
+ export type { ChangeStreamDeleteDocument, ChangeStreamDocument, ChangeStreamInsertDocument, ChangeStreamUpdateDocument, Collection, DeleteOptions, Document, Filter, FindOptions, IndexDescription, InsertOneOptions, InsertOneResult, MongoClientOptions, OptionalUnlessRequiredId, Sort, UpdateDescription, UpdateOptions, UpdateResult, WithId, } from 'mongodb';
@@ -1,6 +1,6 @@
1
1
  import { MongoConnector } from '@tmlmobilidade/connectors';
2
2
  import { type UnixTimestamp } from '@tmlmobilidade/types';
3
- import { Collection, DeleteOptions, DeleteResult, Document, Filter, FindOptions, IndexDescription, InsertOneOptions, InsertOneResult, MongoClientOptions, UpdateOptions, UpdateResult, WithId } from 'mongodb';
3
+ import { AggregateOptions, AggregationCursor, Collection, DeleteOptions, DeleteResult, Document, Filter, FindOptions, IndexDescription, InsertOneOptions, InsertOneResult, MongoClientOptions, UpdateOptions, UpdateResult, WithId } from 'mongodb';
4
4
  import { z } from 'zod';
5
5
  import { AggregationPipeline } from './aggregation-pipeline.js';
6
6
  export declare abstract class MongoCollectionClass<T extends Document, TCreate, TUpdate> {
@@ -11,9 +11,15 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
11
11
  /**
12
12
  * Aggregates documents in the collection.
13
13
  * @param pipeline - The aggregation pipeline to execute
14
+ * @param options - The options for the aggregation operation
14
15
  * @returns A promise that resolves to an array of aggregated documents
15
16
  */
16
- aggregate(pipeline: AggregationPipeline<T>): Promise<T[]>;
17
+ aggregate(pipeline: AggregationPipeline<T>, options?: AggregateOptions & {
18
+ returnResult?: true;
19
+ }): Promise<T[]>;
20
+ aggregate(pipeline: AggregationPipeline<T>, options: AggregateOptions & {
21
+ returnResult: false;
22
+ }): Promise<AggregationCursor<T>>;
17
23
  /**
18
24
  * Gets all documents in the collection.
19
25
  * @returns A promise that resolves to an array of all documents
@@ -8,13 +8,12 @@ export class MongoCollectionClass {
8
8
  mongoCollection;
9
9
  mongoConnector;
10
10
  updateSchema = null;
11
- /**
12
- * Aggregates documents in the collection.
13
- * @param pipeline - The aggregation pipeline to execute
14
- * @returns A promise that resolves to an array of aggregated documents
15
- */
16
- async aggregate(pipeline) {
17
- return await this.mongoCollection.aggregate(pipeline).toArray();
11
+ async aggregate(pipeline, options) {
12
+ const aggregation = this.mongoCollection.aggregate(pipeline, options);
13
+ if (options?.returnResult === false) {
14
+ return aggregation;
15
+ }
16
+ return aggregation.toArray();
18
17
  }
19
18
  /**
20
19
  * Gets all documents in the collection.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/interfaces",
3
- "version": "20250922.953.29",
3
+ "version": "20250924.1552.9",
4
4
  "author": "João de Vasconcelos & Jusi Monteiro",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "homepage": "https://github.com/tmlmobilidade/services#readme",