From caf98709903a751f63380966d3a1727d0d10197d Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Thu, 3 Mar 2022 13:42:01 +0100 Subject: [PATCH] rename mongo collection #223 --- .../src/appobj/DatabaseObjectAppObject.svelte | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/web/src/appobj/DatabaseObjectAppObject.svelte b/packages/web/src/appobj/DatabaseObjectAppObject.svelte index fb5472666..8e264d051 100644 --- a/packages/web/src/appobj/DatabaseObjectAppObject.svelte +++ b/packages/web/src/appobj/DatabaseObjectAppObject.svelte @@ -316,6 +316,10 @@ label: 'Drop collection', isDropCollection: true, }, + { + label: 'Rename collection', + isRenameCollection: true, + }, { divider: true, }, @@ -565,6 +569,20 @@ apiCall('database-connections/sync-model', dbid); }, }); + } else if (menu.isRenameCollection) { + showModal(InputTextModal, { + label: 'New collection name', + header: 'Rename collection', + value: data.pureName, + onConfirm: async newName => { + const dbid = _.pick(data, ['conid', 'database']); + await apiCall('database-connections/run-script', { + ...dbid, + sql: `db.renameCollection('${data.pureName}', '${newName}')`, + }); + apiCall('database-connections/sync-model', dbid); + }, + }); } else { openDatabaseObjectDetail( menu.tab, @@ -608,6 +626,7 @@ import { alterDatabaseDialog, renameDatabaseObjectDialog } from '../utility/alterDatabaseTools'; import ConfirmModal from '../modals/ConfirmModal.svelte'; import { apiCall } from '../utility/api'; + import InputTextModal from '../modals/InputTextModal.svelte'; export let data; export let passProps;