From c7e1e294ef008b23384b10300e6e2076b3701840 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 8 Apr 2021 10:02:04 +0200 Subject: [PATCH] mongo update script preview --- packages/types/engines.d.ts | 4 +++- packages/web/src/modals/ConfirmNoSqlModal.svelte | 6 +++--- packages/web/src/tabs/CollectionDataTab.svelte | 16 +++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/types/engines.d.ts b/packages/types/engines.d.ts index e1666beb..8dfe8f71 100644 --- a/packages/types/engines.d.ts +++ b/packages/types/engines.d.ts @@ -27,11 +27,12 @@ export interface EngineAuthType { export interface ReadCollectionOptions { pureName: string; schemaName?: string; - + countDocuments?: boolean; skip?: number; limit?: number; } + export interface EngineDriver { engine: string; title: string; @@ -62,6 +63,7 @@ export interface EngineDriver { getAuthTypes(): EngineAuthType[]; readCollection(pool: any, options: ReadCollectionOptions): Promise; updateCollection(pool: any, changeSet: any): Promise; + getCollectionUpdateScript(changeSet: any): string; analyserClass?: any; dumperClass?: any; diff --git a/packages/web/src/modals/ConfirmNoSqlModal.svelte b/packages/web/src/modals/ConfirmNoSqlModal.svelte index 67513ea6..473e674f 100644 --- a/packages/web/src/modals/ConfirmNoSqlModal.svelte +++ b/packages/web/src/modals/ConfirmNoSqlModal.svelte @@ -3,11 +3,12 @@ import FormProvider from '../forms/FormProvider.svelte'; import FormSubmit from '../forms/FormSubmit.svelte'; import JSONTree from '../jsontree/JSONTree.svelte'; + import AceEditor from '../query/AceEditor.svelte'; import ModalBase from './ModalBase.svelte'; import { closeCurrentModal } from './modalTools'; - export let json; + export let script; export let onConfirm; @@ -16,7 +17,7 @@
Save changes
- +
@@ -37,6 +38,5 @@ position: relative; height: 30vh; width: 40vw; - overflow: scroll; } diff --git a/packages/web/src/tabs/CollectionDataTab.svelte b/packages/web/src/tabs/CollectionDataTab.svelte index 25cc0b68..401fc2e1 100644 --- a/packages/web/src/tabs/CollectionDataTab.svelte +++ b/packages/web/src/tabs/CollectionDataTab.svelte @@ -118,11 +118,17 @@ export function save() { const json = $changeSetStore?.value; - showModal(ConfirmNoSqlModal, { - json, - onConfirm: () => handleConfirmChange(json), - engine: display.engine, - }); + const driver = findEngineDriver($connection, $extensions); + const script = driver.getCollectionUpdateScript ? driver.getCollectionUpdateScript(json) : null; + if (script) { + showModal(ConfirmNoSqlModal, { + script, + onConfirm: () => handleConfirmChange(json), + engine: display.engine, + }); + } else { + handleConfirmChange(json); + } } export function addJsonDocument() {