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;
profilerChartMeasures?: { label: string; field: string }[];
isElectronOnly?: boolean;
collectionSingularLabel?: string;
collectionPluralLabel?: string;
collectionNameLabel?: string;
newCollectionFormParams?: any[];
supportedCreateDatabase?: boolean;
showConnectionField?: (
field: string,

View File

@@ -12,9 +12,9 @@
</script>
{#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'}
<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'}
<FormCheckboxField label={arg.label} {name} defaultValue={arg.default} />
{:else if arg.type == 'select'}

View File

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

View File

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

View File

@@ -110,8 +110,10 @@ const driver = {
switch (type) {
case 'createCollection':
await this.script(pool, `db.createCollection('${operation.collection.name}')`);
case 'dropOperation':
break;
case 'dropCollection':
await this.script(pool, `db.dropCollection('${operation.collection}')`);
break;
default:
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) {
let res = '';
for (const insert of changeSet.inserts) {