@dnax/core 0.70.7 → 0.70.8
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/driver/mongo/rest.ts +13 -0
- package/package.json +1 -1
package/driver/mongo/rest.ts
CHANGED
|
@@ -127,6 +127,7 @@ class useRest {
|
|
|
127
127
|
db: Tenant["database"]["db"];
|
|
128
128
|
activity: {
|
|
129
129
|
save: (activity: activityInput) => Promise<any>;
|
|
130
|
+
aggregate: (pipeline: Array<object>) => Promise<Array<any>>;
|
|
130
131
|
list: (
|
|
131
132
|
collection: string,
|
|
132
133
|
filter?: {
|
|
@@ -154,6 +155,9 @@ class useRest {
|
|
|
154
155
|
client: this.#tenant.searchEngine?.meilisearch?.client!,
|
|
155
156
|
};
|
|
156
157
|
this.activity = {
|
|
158
|
+
aggregate: async (pipeline: Array<object>) => {
|
|
159
|
+
return await restActivity.aggregate(this.#tenant, pipeline);
|
|
160
|
+
},
|
|
157
161
|
save: async (activityInput: activityInput) => {
|
|
158
162
|
return await restActivity.save(this.#tenant, activityInput);
|
|
159
163
|
},
|
|
@@ -292,6 +296,7 @@ class useRest {
|
|
|
292
296
|
let useHook = options?.useHook ?? this.#useHook;
|
|
293
297
|
let sharedData = {};
|
|
294
298
|
let col = getCollection(collection, this.#tenant_id);
|
|
299
|
+
|
|
295
300
|
if (!col) return fn.error(`Collection ${collection} not found`, 404);
|
|
296
301
|
|
|
297
302
|
if (col?.hooks?.beforeOperation && useHook) {
|
|
@@ -2607,6 +2612,14 @@ const restActivity = {
|
|
|
2607
2612
|
$skip?: number;
|
|
2608
2613
|
}
|
|
2609
2614
|
) => {},
|
|
2615
|
+
aggregate: async (tenant: Tenant, pipeline: Array<object>): Promise<any> => {
|
|
2616
|
+
return await tenant.database.db
|
|
2617
|
+
?.collection("_activity_")
|
|
2618
|
+
.aggregate(toBson(pipeline), {
|
|
2619
|
+
allowDiskUse: true,
|
|
2620
|
+
})
|
|
2621
|
+
.toArray();
|
|
2622
|
+
},
|
|
2610
2623
|
save: async (tenant: Tenant, activity: activityInput) => {
|
|
2611
2624
|
return await tenant.database.db
|
|
2612
2625
|
?.collection("_activity_")
|