mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
Refactor DbKeyDetailTab to streamline insert handling for Redis data types
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user