From eaf6a5e40c23de9005e32abb60adef4ce90582d8 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Mon, 3 Oct 2022 20:08:47 +0100 Subject: [PATCH] Add aggregate method. Push results. --- packages/server/src/integrations/mongodb.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/mongodb.ts b/packages/server/src/integrations/mongodb.ts index a5dfdc8f0f..b5fed323a5 100644 --- a/packages/server/src/integrations/mongodb.ts +++ b/packages/server/src/integrations/mongodb.ts @@ -56,6 +56,9 @@ const SCHEMA: Integration = { delete: { type: QueryType.JSON, }, + aggregate: { + type: QueryType.FLOW, + }, }, extra: { collection: { @@ -327,7 +330,7 @@ class MongoIntegration implements IntegrationBase { await this.connect() const db = this.client.db(this.config.db) const collection = db.collection(query.extra.collection) - let response = {} + let response = [] for await (const doc of collection.aggregate( query.steps.map(({ key, value }) => { let temp: any = {} @@ -335,7 +338,7 @@ class MongoIntegration implements IntegrationBase { return temp }) )) { - response = doc + response.push(doc) } return response } catch (err) {