Refactor DbKeyDetailTab to streamline insert handling for Redis data types

This commit is contained in:
Stela Augustinova
2025-12-23 19:32:50 +01:00
parent 6689849f97
commit 3078e3584c

View File

@@ -182,8 +182,6 @@
changes: [...changeSetRedis.changes, change] changes: [...changeSetRedis.changes, change]
}; };
} }
console.log('ChangeSetRedis updated:', JSON.stringify(changeSetRedis, null, 2));
} }
function getDisplayRow(row, keyInfo) { function getDisplayRow(row, keyInfo) {
@@ -236,12 +234,12 @@
c => c.key === keyInfo.key && c.type === keyInfo.type c => c.key === keyInfo.key && c.type === keyInfo.type
); );
if (!existingChange || !existingChange.inserts) { let records = [];
return null;
}
// Add existing inserts if any
if (existingChange && existingChange.inserts) {
// @ts-ignore // @ts-ignore
const records = existingChange.inserts.map(insert => { records = existingChange.inserts.map(insert => {
if (keyInfo.type === 'hash') { if (keyInfo.type === 'hash') {
return { key: insert.key || '', value: insert.value || '', ttl: insert.ttl ? String(insert.ttl) : '' }; return { key: insert.key || '', value: insert.value || '', ttl: insert.ttl ? String(insert.ttl) : '' };
} else if (keyInfo.type === 'list' || keyInfo.type === 'set') { } else if (keyInfo.type === 'list' || keyInfo.type === 'set') {
@@ -253,6 +251,19 @@
} }
return insert; return insert;
}); });
}
if (records.length === 0) {
if (keyInfo.type === 'hash') {
records.push({ key: '', value: '', ttl: '' });
} else if (keyInfo.type === 'list' || keyInfo.type === 'set') {
records.push({ value: '' });
} else if (keyInfo.type === 'zset') {
records.push({ member: '', score: '' });
} else if (keyInfo.type === 'stream') {
records.push({ id: '', value: '' });
}
}
return { records }; return { records };
} }
@@ -264,7 +275,6 @@
} }
async function saveAll() { async function saveAll() {
console.log('Saving all changes:', changeSetRedis);
await apiCall('database-connections/save-redis-data', { await apiCall('database-connections/save-redis-data', {
conid, conid,
database, database,