Add aggregate method. Push results.
This commit is contained in:
parent
6ef497992a
commit
eaf6a5e40c
|
@ -56,6 +56,9 @@ const SCHEMA: Integration = {
|
||||||
delete: {
|
delete: {
|
||||||
type: QueryType.JSON,
|
type: QueryType.JSON,
|
||||||
},
|
},
|
||||||
|
aggregate: {
|
||||||
|
type: QueryType.FLOW,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extra: {
|
extra: {
|
||||||
collection: {
|
collection: {
|
||||||
|
@ -327,7 +330,7 @@ class MongoIntegration implements IntegrationBase {
|
||||||
await this.connect()
|
await this.connect()
|
||||||
const db = this.client.db(this.config.db)
|
const db = this.client.db(this.config.db)
|
||||||
const collection = db.collection(query.extra.collection)
|
const collection = db.collection(query.extra.collection)
|
||||||
let response = {}
|
let response = []
|
||||||
for await (const doc of collection.aggregate(
|
for await (const doc of collection.aggregate(
|
||||||
query.steps.map(({ key, value }) => {
|
query.steps.map(({ key, value }) => {
|
||||||
let temp: any = {}
|
let temp: any = {}
|
||||||
|
@ -335,7 +338,7 @@ class MongoIntegration implements IntegrationBase {
|
||||||
return temp
|
return temp
|
||||||
})
|
})
|
||||||
)) {
|
)) {
|
||||||
response = doc
|
response.push(doc)
|
||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue