mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 20:16:00 +00:00
Implement saveRedisData functionality and update API call in DbKeyDetailTab
This commit is contained in:
@@ -494,6 +494,20 @@ module.exports = {
|
||||
return res.result || null;
|
||||
},
|
||||
|
||||
saveRedisData_meta: true,
|
||||
async saveRedisData({ conid, database, changeSet }, req) {
|
||||
await testConnectionPermission(conid, req);
|
||||
|
||||
const opened = await this.ensureOpened(conid, database);
|
||||
const res = await this.sendRequest(opened, { msgtype: 'saveRedisData', changeSet });
|
||||
if (res.errorMessage) {
|
||||
return {
|
||||
errorMessage: res.errorMessage,
|
||||
};
|
||||
}
|
||||
return res.result || null;
|
||||
},
|
||||
|
||||
status_meta: true,
|
||||
async status({ conid, database }, req) {
|
||||
if (!conid) {
|
||||
|
||||
@@ -368,6 +368,30 @@ async function handleSaveTableData({ msgid, changeSet }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaveRedisData({ msgid, changeSet }) {
|
||||
try {
|
||||
const driver = requireEngineDriver(storedConnection);
|
||||
|
||||
if (!changeSet || !changeSet.changes || !Array.isArray(changeSet.changes)) {
|
||||
throw new Error('Invalid changeSet structure');
|
||||
}
|
||||
|
||||
for (const change of changeSet.changes) {
|
||||
if (change.type === 'string') {
|
||||
await driver.query(dbhan, `SET "${change.key}" "${change.value}"`);
|
||||
}
|
||||
}
|
||||
|
||||
process.send({ msgtype: 'response', msgid });
|
||||
} catch (err) {
|
||||
process.send({
|
||||
msgtype: 'response',
|
||||
msgid,
|
||||
errorMessage: extractErrorMessage(err, 'Error saving Redis data'),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSqlPreview({ msgid, objects, options }) {
|
||||
await waitStructure();
|
||||
const driver = requireEngineDriver(storedConnection);
|
||||
@@ -501,6 +525,7 @@ const messageHandlers = {
|
||||
schemaList: handleSchemaList,
|
||||
executeSessionQuery: handleExecuteSessionQuery,
|
||||
evalJsonScript: handleEvalJsonScript,
|
||||
saveRedisData: handleSaveRedisData,
|
||||
// runCommand: handleRunCommand,
|
||||
};
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@
|
||||
|
||||
async function saveAll() {
|
||||
console.log('Saving all changes:', changeSetRedis);
|
||||
await apiCall('database-connections/apply-redis-change-set', {
|
||||
await apiCall('database-connections/save-redis-data', {
|
||||
conid,
|
||||
database,
|
||||
changeSet: changeSetRedis,
|
||||
|
||||
Reference in New Issue
Block a user