mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
redis export keys
This commit is contained in:
parent
c0fdcf2fd1
commit
1f0ae98c88
@ -180,6 +180,11 @@ module.exports = {
|
||||
return this.loadDataCore('loadKeys', { conid, database, root });
|
||||
},
|
||||
|
||||
exportKeys_meta: true,
|
||||
async exportKeys({ conid, database, options }) {
|
||||
return this.loadDataCore('exportKeys', { conid, database, options });
|
||||
},
|
||||
|
||||
loadKeyInfo_meta: true,
|
||||
async loadKeyInfo({ conid, database, key }) {
|
||||
return this.loadDataCore('loadKeyInfo', { conid, database, key });
|
||||
|
@ -201,6 +201,10 @@ async function handleLoadKeys({ msgid, root }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.loadKeys(systemConnection, root));
|
||||
}
|
||||
|
||||
async function handleExportKeys({ msgid, options }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.exportKeys(systemConnection, options));
|
||||
}
|
||||
|
||||
async function handleLoadKeyInfo({ msgid, key }) {
|
||||
return handleDriverDataCore(msgid, driver => driver.loadKeyInfo(systemConnection, key));
|
||||
}
|
||||
@ -307,6 +311,7 @@ const messageHandlers = {
|
||||
generateDeploySql: handleGenerateDeploySql,
|
||||
loadFieldValues: handleLoadFieldValues,
|
||||
sqlSelect: handleSqlSelect,
|
||||
exportKeys: handleExportKeys,
|
||||
// runCommand: handleRunCommand,
|
||||
};
|
||||
|
||||
|
1
packages/types/engines.d.ts
vendored
1
packages/types/engines.d.ts
vendored
@ -89,6 +89,7 @@ export interface EngineDriver {
|
||||
}[]
|
||||
>;
|
||||
loadKeys(pool, root: string): Promise;
|
||||
exportKeys(pool, options: {}): Promise;
|
||||
loadKeyInfo(pool, key): Promise;
|
||||
loadKeyTableRange(pool, key, cursor, count): Promise;
|
||||
loadFieldValues(pool: any, name: NamedObjectInfo, field: string, search: string): Promise;
|
||||
|
@ -6,6 +6,7 @@
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import newQuery from '../query/newQuery';
|
||||
import { activeDbKeysStore } from '../stores';
|
||||
import { apiCall } from '../utility/api';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
@ -77,6 +78,23 @@
|
||||
},
|
||||
},
|
||||
],
|
||||
{
|
||||
label: 'Generate script',
|
||||
onClick: async () => {
|
||||
const data = await apiCall('database-connections/export-keys', {
|
||||
conid,
|
||||
database,
|
||||
options: {
|
||||
keyPrefix: item.root || item.key,
|
||||
},
|
||||
});
|
||||
|
||||
newQuery({
|
||||
title: 'Export #',
|
||||
initialData: data,
|
||||
});
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
@ -163,6 +163,20 @@ const driver = {
|
||||
return res;
|
||||
},
|
||||
|
||||
async exportKeys(pool, options) {
|
||||
const dump = new RedisDump({ client: pool });
|
||||
return new Promise((resolve, reject) => {
|
||||
dump.export({
|
||||
type: 'redis',
|
||||
keyPrefix: options.keyPrefix,
|
||||
callback: (err, data) => {
|
||||
if (err) reject(err);
|
||||
else resolve(data);
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
async getKeys(pool, keyQuery = '*') {
|
||||
const res = [];
|
||||
let cursor = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user