Add delete button

This commit is contained in:
Mel O'Hagan 2022-08-25 17:40:09 +01:00
parent 52c8fda064
commit f2881fc714
2 changed files with 17 additions and 8 deletions

View File

@ -67,7 +67,7 @@
{/if}
{:else if schema.type === QueryTypes.FLOW}
<br />
{#if !query.fields.steps}
{#if query.fields.steps?.length == 0}
<div class="controls">
<Button
secondary
@ -91,7 +91,14 @@
<div class="blockSection">
<div class="block-options">
Stage {index + 1}
<ActionButton on:click={() => {}} icon="DeleteOutline" />
<ActionButton
on:click={() => {
query.fields.steps = [
...query.fields.steps.splice(index, 1),
]
}}
icon="DeleteOutline"
/>
</div>
<Layout noPadding gap="S">
<div class="fields">

View File

@ -52,7 +52,7 @@ module MongoDBModule {
},
aggregate: {
type: QueryType.FLOW,
}
},
},
extra: {
collection: {
@ -327,11 +327,13 @@ module MongoDBModule {
const db = this.client.db(this.config.db)
const collection = db.collection(query.extra.collection)
let response = {}
for await (const doc of collection.aggregate(query.steps.map(({ key, value }) => {
for await (const doc of collection.aggregate(
query.steps.map(({ key, value }) => {
let temp: any = {}
temp[key] = JSON.parse(value.value)
return temp
}))) {
})
)) {
response = doc
}
return response