new collection refactor + mongo drop collection fixed

This commit is contained in:
Jan Prochazka
2024-08-22 10:41:29 +02:00
parent 77b42e6a04
commit 7ad8edcdae
6 changed files with 21 additions and 5 deletions

View File

@@ -115,8 +115,12 @@ export interface EngineDriver extends FilterBehaviourProvider {
profilerChartAggregateFunction?: string; profilerChartAggregateFunction?: string;
profilerChartMeasures?: { label: string; field: string }[]; profilerChartMeasures?: { label: string; field: string }[];
isElectronOnly?: boolean; isElectronOnly?: boolean;
collectionSingularLabel?: string; collectionSingularLabel?: string;
collectionPluralLabel?: string; collectionPluralLabel?: string;
collectionNameLabel?: string;
newCollectionFormParams?: any[];
supportedCreateDatabase?: boolean; supportedCreateDatabase?: boolean;
showConnectionField?: ( showConnectionField?: (
field: string, field: string,

View File

@@ -12,9 +12,9 @@
</script> </script>
{#if arg.type == 'text'} {#if arg.type == 'text'}
<FormTextField label={arg.label} {name} defaultValue={arg.default} /> <FormTextField label={arg.label} {name} defaultValue={arg.default} focused={arg.focused} />
{:else if arg.type == 'number'} {:else if arg.type == 'number'}
<FormTextField label={arg.label} type="number" {name} defaultValue={arg.default} /> <FormTextField label={arg.label} type="number" {name} defaultValue={arg.default} focused={arg.focused} />
{:else if arg.type == 'checkbox'} {:else if arg.type == 'checkbox'}
<FormCheckboxField label={arg.label} {name} defaultValue={arg.default} /> <FormCheckboxField label={arg.label} {name} defaultValue={arg.default} />
{:else if arg.type == 'select'} {:else if arg.type == 'select'}

View File

@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import FormArgument from './FormArgument.svelte'; import FormArgument from './FormArgument.svelte';
export let namePrefix; export let namePrefix = '';
export let args: any[]; export let args: any[];
</script> </script>

View File

@@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import FormStyledButton from '../buttons/FormStyledButton.svelte'; import FormStyledButton from '../buttons/FormStyledButton.svelte';
import FormArgumentList from '../forms/FormArgumentList.svelte';
import FormProvider from '../forms/FormProvider.svelte'; import FormProvider from '../forms/FormProvider.svelte';
import FormSubmit from '../forms/FormSubmit.svelte'; import FormSubmit from '../forms/FormSubmit.svelte';
@@ -22,7 +23,7 @@
Create {driver?.collectionSingularLabel ?? 'collection/container'} Create {driver?.collectionSingularLabel ?? 'collection/container'}
</svelte:fragment> </svelte:fragment>
<FormTextField label={`New ${driver?.collectionSingularLabel ?? 'collection/container'} name`} name="name" focused /> <FormArgumentList args={driver?.newCollectionFormParams} />
<svelte:fragment slot="footer"> <svelte:fragment slot="footer">
<FormSubmit value="OK" on:click={e => handleSubmit(e.detail)} /> <FormSubmit value="OK" on:click={e => handleSubmit(e.detail)} />

View File

@@ -110,8 +110,10 @@ const driver = {
switch (type) { switch (type) {
case 'createCollection': case 'createCollection':
await this.script(pool, `db.createCollection('${operation.collection.name}')`); await this.script(pool, `db.createCollection('${operation.collection.name}')`);
case 'dropOperation': break;
case 'dropCollection':
await this.script(pool, `db.dropCollection('${operation.collection}')`); await this.script(pool, `db.dropCollection('${operation.collection}')`);
break;
default: default:
throw new Error(`Operation type ${type} not supported`); throw new Error(`Operation type ${type} not supported`);
} }

View File

@@ -67,6 +67,15 @@ const driver = {
}, },
], ],
newCollectionFormParams: [
{
type: 'text',
label: 'Collection name',
name: 'name',
focused: true,
},
],
getCollectionUpdateScript(changeSet, collectionInfo) { getCollectionUpdateScript(changeSet, collectionInfo) {
let res = ''; let res = '';
for (const insert of changeSet.inserts) { for (const insert of changeSet.inserts) {