mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 21:26: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;
|
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,
|
status_meta: true,
|
||||||
async status({ conid, database }, req) {
|
async status({ conid, database }, req) {
|
||||||
if (!conid) {
|
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 }) {
|
async function handleSqlPreview({ msgid, objects, options }) {
|
||||||
await waitStructure();
|
await waitStructure();
|
||||||
const driver = requireEngineDriver(storedConnection);
|
const driver = requireEngineDriver(storedConnection);
|
||||||
@@ -501,6 +525,7 @@ const messageHandlers = {
|
|||||||
schemaList: handleSchemaList,
|
schemaList: handleSchemaList,
|
||||||
executeSessionQuery: handleExecuteSessionQuery,
|
executeSessionQuery: handleExecuteSessionQuery,
|
||||||
evalJsonScript: handleEvalJsonScript,
|
evalJsonScript: handleEvalJsonScript,
|
||||||
|
saveRedisData: handleSaveRedisData,
|
||||||
// runCommand: handleRunCommand,
|
// runCommand: handleRunCommand,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,7 @@
|
|||||||
|
|
||||||
async function saveAll() {
|
async function saveAll() {
|
||||||
console.log('Saving all changes:', changeSetRedis);
|
console.log('Saving all changes:', changeSetRedis);
|
||||||
await apiCall('database-connections/apply-redis-change-set', {
|
await apiCall('database-connections/save-redis-data', {
|
||||||
conid,
|
conid,
|
||||||
database,
|
database,
|
||||||
changeSet: changeSetRedis,
|
changeSet: changeSetRedis,
|
||||||
|
|||||||
Reference in New Issue
Block a user