mongo update script preview

This commit is contained in:
Jan Prochazka
2021-04-08 10:02:04 +02:00
parent 1bf9110f4b
commit c7e1e294ef
3 changed files with 17 additions and 9 deletions

View File

@@ -27,11 +27,12 @@ export interface EngineAuthType {
export interface ReadCollectionOptions { export interface ReadCollectionOptions {
pureName: string; pureName: string;
schemaName?: string; schemaName?: string;
countDocuments?: boolean; countDocuments?: boolean;
skip?: number; skip?: number;
limit?: number; limit?: number;
} }
export interface EngineDriver { export interface EngineDriver {
engine: string; engine: string;
title: string; title: string;
@@ -62,6 +63,7 @@ export interface EngineDriver {
getAuthTypes(): EngineAuthType[]; getAuthTypes(): EngineAuthType[];
readCollection(pool: any, options: ReadCollectionOptions): Promise<any>; readCollection(pool: any, options: ReadCollectionOptions): Promise<any>;
updateCollection(pool: any, changeSet: any): Promise<any>; updateCollection(pool: any, changeSet: any): Promise<any>;
getCollectionUpdateScript(changeSet: any): string;
analyserClass?: any; analyserClass?: any;
dumperClass?: any; dumperClass?: any;

View File

@@ -3,11 +3,12 @@
import FormProvider from '../forms/FormProvider.svelte'; import FormProvider from '../forms/FormProvider.svelte';
import FormSubmit from '../forms/FormSubmit.svelte'; import FormSubmit from '../forms/FormSubmit.svelte';
import JSONTree from '../jsontree/JSONTree.svelte'; import JSONTree from '../jsontree/JSONTree.svelte';
import AceEditor from '../query/AceEditor.svelte';
import ModalBase from './ModalBase.svelte'; import ModalBase from './ModalBase.svelte';
import { closeCurrentModal } from './modalTools'; import { closeCurrentModal } from './modalTools';
export let json; export let script;
export let onConfirm; export let onConfirm;
</script> </script>
@@ -16,7 +17,7 @@
<div slot="header">Save changes</div> <div slot="header">Save changes</div>
<div class="editor"> <div class="editor">
<JSONTree value={json} /> <AceEditor mode="javascript" readOnly value={script} />
</div> </div>
<div slot="footer"> <div slot="footer">
@@ -37,6 +38,5 @@
position: relative; position: relative;
height: 30vh; height: 30vh;
width: 40vw; width: 40vw;
overflow: scroll;
} }
</style> </style>

View File

@@ -118,11 +118,17 @@
export function save() { export function save() {
const json = $changeSetStore?.value; const json = $changeSetStore?.value;
showModal(ConfirmNoSqlModal, { const driver = findEngineDriver($connection, $extensions);
json, const script = driver.getCollectionUpdateScript ? driver.getCollectionUpdateScript(json) : null;
onConfirm: () => handleConfirmChange(json), if (script) {
engine: display.engine, showModal(ConfirmNoSqlModal, {
}); script,
onConfirm: () => handleConfirmChange(json),
engine: display.engine,
});
} else {
handleConfirmChange(json);
}
} }
export function addJsonDocument() { export function addJsonDocument() {