mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
mongo update script preview
This commit is contained in:
parent
1bf9110f4b
commit
c7e1e294ef
2
packages/types/engines.d.ts
vendored
2
packages/types/engines.d.ts
vendored
@ -32,6 +32,7 @@ export interface ReadCollectionOptions {
|
||||
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<any>;
|
||||
updateCollection(pool: any, changeSet: any): Promise<any>;
|
||||
getCollectionUpdateScript(changeSet: any): string;
|
||||
|
||||
analyserClass?: any;
|
||||
dumperClass?: any;
|
||||
|
@ -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;
|
||||
</script>
|
||||
|
||||
@ -16,7 +17,7 @@
|
||||
<div slot="header">Save changes</div>
|
||||
|
||||
<div class="editor">
|
||||
<JSONTree value={json} />
|
||||
<AceEditor mode="javascript" readOnly value={script} />
|
||||
</div>
|
||||
|
||||
<div slot="footer">
|
||||
@ -37,6 +38,5 @@
|
||||
position: relative;
|
||||
height: 30vh;
|
||||
width: 40vw;
|
||||
overflow: scroll;
|
||||
}
|
||||
</style>
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user