@tmlmobilidade/interfaces 20250827.1127.52 → 20250827.1228.57
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.
|
@@ -7,6 +7,7 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
7
7
|
protected mongoCollection: Collection<T>;
|
|
8
8
|
protected mongoConnector: MongoConnector;
|
|
9
9
|
protected updateSchema: null | z.ZodSchema;
|
|
10
|
+
aggregate(pipeline: AggregationPipeline<T>): Promise<Document[]>;
|
|
10
11
|
/**
|
|
11
12
|
* Gets all documents in the collection.
|
|
12
13
|
* @returns A promise that resolves to an array of all documents
|
|
@@ -146,3 +147,27 @@ export declare abstract class MongoCollectionClass<T extends Document, TCreate,
|
|
|
146
147
|
protected abstract getCollectionName(): string;
|
|
147
148
|
protected abstract getEnvName(): string;
|
|
148
149
|
}
|
|
150
|
+
interface MatchStage<T> {
|
|
151
|
+
$match: Partial<T>;
|
|
152
|
+
}
|
|
153
|
+
interface ProjectStage<T> {
|
|
154
|
+
$project: Partial<Record<keyof T, 0 | 1>>;
|
|
155
|
+
}
|
|
156
|
+
interface GroupStage<T> {
|
|
157
|
+
$group: {
|
|
158
|
+
[key: string]: any;
|
|
159
|
+
_id: Record<string, keyof T> | string;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
interface SortStage<T> {
|
|
163
|
+
$sort: Partial<Record<keyof T, -1 | 1>>;
|
|
164
|
+
}
|
|
165
|
+
interface LimitStage {
|
|
166
|
+
$limit: number;
|
|
167
|
+
}
|
|
168
|
+
interface SkipStage {
|
|
169
|
+
$skip: number;
|
|
170
|
+
}
|
|
171
|
+
type AggregationStage<T> = GroupStage<T> | LimitStage | MatchStage<T> | ProjectStage<T> | SkipStage | SortStage<T>;
|
|
172
|
+
export type AggregationPipeline<T> = AggregationStage<T>[];
|
|
173
|
+
export {};
|
|
@@ -8,6 +8,9 @@ export class MongoCollectionClass {
|
|
|
8
8
|
mongoCollection;
|
|
9
9
|
mongoConnector;
|
|
10
10
|
updateSchema = null;
|
|
11
|
+
async aggregate(pipeline) {
|
|
12
|
+
return await this.mongoCollection.aggregate(pipeline).toArray();
|
|
13
|
+
}
|
|
11
14
|
/**
|
|
12
15
|
* Gets all documents in the collection.
|
|
13
16
|
* @returns A promise that resolves to an array of all documents
|
package/package.json
CHANGED