Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(redis): choose head or tail when pushing into lists

yangzidemuoua88f8dabe757
diff --git a/apps/desktop/src/components/redis/RedisValueViewer.listPushSide.spec.ts b/apps/desktop/src/components/redis/RedisValueViewer.listPushSide.spec.ts
new file mode 100644
index 0000000000..de362f7a87
--- /dev/null
+++ b/apps/desktop/src/components/redis/RedisValueViewer.listPushSide.spec.ts
@@ -0,0 +1,147 @@
+// @vitest-environment happy-dom
+
+import { createApp, defineComponent, h, nextTick } from "vue";
+import { createI18n } from "vue-i18n";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+const mocks = vi.hoisted(() => ({
+ redisGetValue: vi.fn(),
+ redisGetTtl: vi.fn(),
+ redisSetTtl: vi.fn(),
+ redisSetExpireAt: vi.fn(),
+ redisListPush: vi.fn(),
+ toast: vi.fn(),
+}));
+
+vi.mock("@/lib/backend/api", () => ({
+ redisGetValue: mocks.redisGetValue,
+ redisGetTtl: mocks.redisGetTtl,
+ redisSetTtl: mocks.redisSetTtl,
+ redisSetExpireAt: mocks.redisSetExpireAt,
+ redisListPush: mocks.redisListPush,
+}));
+vi.mock("@/composables/useEditorFontFamilyStyle", () => ({ useEditorFontFamilyStyle: () => ({}) }));
+vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: mocks.toast }) }));
+vi.mock("@/lib/common/shikiJsonHighlighter", () => ({ createShikiJsonHighlighter: vi.fn().mockResolvedValue(() => "") }));
+
+import RedisValueViewer from "./RedisValueViewer.vue";
+
+const mountedApps: Array<{ unmount: () => void; host: HTMLElement }> = [];
+
+async function settleRounds(rounds = 4) {
+ for (let i = 0; i < rounds; i++) {
+ await nextTick();
+ await Promise.resolve();
+ }
+}
+
+afterEach(() => {
+ for (const { unmount, host } of mountedApps.splice(0)) {
+ unmount();
+ host.remove();
+ }
+});
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ mocks.redisListPush.mockResolvedValue(undefined);
+ mocks.redisGetValue.mockResolvedValue({
+ key_display: "queue",
+ key_raw: "queue",
+ ttl: -1,
+ redis_type: "list",
+ data: {
+ kind: "list",
+ items: [
+ { index: 0, value: { raw_base64: "Zmlyc3Q=", encoding: "utf8" } },
+ { index: 1, value: { raw_base64: "c2Vjb25k", encoding: "utf8" } },
+ ],
+ total: 2,
+ },
+ });
+});
+
+async function mountListViewer() {
+ const host = document.createElement("div");
+ document.body.append(host);
+ const app = createApp(
+ defineComponent({
+ setup: () => () => h(RedisValueViewer, { connectionId: "connection", db: 0, keyDisplay: "queue", keyRaw: "queue" }),
+ }),
+ );
+ app.use(
+ createI18n({
+ legacy: false,
+ locale: "en",
+ messages: { en: { redis: { pushAction: "Push", pushSide: "Push position", pushSideLeft: "Head (LPUSH)", pushSideRight: "Tail (RPUSH)", valuePlaceholder: "New value" } } },
+ missingWarn: false,
+ fallbackWarn: false,
+ }),
+ );
+ app.mount(host);
+ mountedApps.push({ unmount: () => app.unmount(), host });
+ await settleRounds();
+ return host;
+}
+
+function newValueInput(host: HTMLElement): HTMLInputElement {
+ const input = host.querySelector<HTMLInputElement>("input[placeholder='New value']");
+ if (!input) throw new Error("New-value input not found");
+ return input;
+}
+
+async function typeAndPush(host: HTMLElement, value: string) {
+ const input = newValueInput(host);
+ input.value = value;
+ input.dispatchEvent(new Event("input", { bubbles: true }));
+ await nextTick();
+ const button = [...host.querySelectorAll("button")].find((candidate) => candidate.textContent?.includes("Push"));
+ if (!button) throw new Error("Push button not found");
+ button.click();
+ await settleRounds();
+}
+
+async function selectSide(host: HTMLElement, side: "left" | "right") {
+ const label = side === "left" ? "Head (LPUSH)" : "Tail (RPUSH)";
+ const trigger = host.querySelector<HTMLButtonElement>("[role='combobox']");
+ if (!trigger) throw new Error("Push-side select trigger not found");
+ // reka-ui's Select opens from keyboard events in happy-dom; a plain click is ignored.
+ trigger.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
+ await settleRounds(2);
+ const option = [...document.querySelectorAll<HTMLElement>("[role='option']")].find((candidate) => candidate.textContent?.includes(label));
+ if (!option) throw new Error(`Push-side option not found: ${side}`);
+ // reka-ui commits the selection from a keydown on the item, not from click.
+ option.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
+ await settleRounds(2);
+}
+
+describe("RedisValueViewer list push side", () => {
+ it("pushes to the tail (RPUSH) by default", async () => {
+ const host = await mountListViewer();
+
+ await typeAndPush(host, "queued");
+
+ expect(mocks.redisListPush).toHaveBeenCalledWith("connection", 0, "queue", "queued", undefined, "right");
+ });
+
+ it("pushes to the head (LPUSH) after switching the side select", async () => {
+ const host = await mountListViewer();
+
+ await selectSide(host, "left");
+ await typeAndPush(host, "urgent");
+
+ expect(mocks.redisListPush).toHaveBeenCalledWith("connection", 0, "queue", "urgent", undefined, "left");
+ });
+
+ it("keeps the selected side for subsequent pushes and clears the input", async () => {
+ const host = await mountListViewer();
+
+ await selectSide(host, "left");
+ await typeAndPush(host, "first");
+ await typeAndPush(host, "second");
+
+ expect(mocks.redisListPush).toHaveBeenCalledTimes(2);
+ expect(mocks.redisListPush.mock.calls.every((call) => call[5] === "left")).toBe(true);
+ expect(newValueInput(host).value).toBe("");
+ });
+});
diff --git a/apps/desktop/src/components/redis/RedisValueViewer.vue b/apps/desktop/src/components/redis/RedisValueViewer.vue
index 0533470a79..9c11a9542e 100644
--- a/apps/desktop/src/components/redis/RedisValueViewer.vue
+++ b/apps/desktop/src/components/redis/RedisValueViewer.vue
@@ -157,6 +157,8 @@ const savingJson = ref(false);
const newField = ref("");
const newValue = ref("");
const newScore = ref("");
+// Queue side for pushing into a list: "right" (RPUSH, historical default) or "left" (LPUSH).
+const listPushSide = ref<"left" | "right">("right");
const showDeleteConfirm = ref(false);
const showMemberDetail = ref(false);
const editingTtl = ref(false);
@@ -2632,7 +2634,7 @@ async function listPush() {
toast(t("redis.valueRequired"), 3000);
return;
}
- await api.redisListPush(props.connectionId, props.db, props.keyRaw, newValue.value);
+ await api.redisListPush(props.connectionId, props.db, props.keyRaw, newValue.value, undefined, listPushSide.value);
newValue.value = "";
await load();
}
@@ -3182,6 +3184,15 @@ useUpdateBlocker(() => (hasUnsavedRedisDraft.value || editingTtl.value || saving
<span class="text-xs text-muted-foreground shrink-0">{{ collectionCountLabel("items", listRows.length, activeCollectionSearchQuery ? null : collectionTotal) }}</span>
<span class="flex-1" />
<Input v-model="newValue" class="h-6 w-40 text-xs" :placeholder="t('redis.valuePlaceholder')" @keydown.enter="listPush" />
+ <Select v-model="listPushSide">
+ <SelectTrigger class="h-6 w-auto min-w-[120px] gap-1 px-2 text-xs" :aria-label="t('redis.pushSide')">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="right" class="text-xs">{{ t("redis.pushSideRight") }}</SelectItem>
+ <SelectItem value="left" class="text-xs">{{ t("redis.pushSideLeft") }}</SelectItem>
+ </SelectContent>
+ </Select>
<Button variant="ghost" size="sm" class="h-6 text-xs" @click="listPush"><Plus class="w-3 h-3 mr-1" />{{ t("redis.pushAction") }}</Button>
</div>
<div class="grid grid-cols-[60px_1fr_84px] border-b bg-muted/50 shrink-0">
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index bbdc2aae3e..a0598139eb 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -5564,6 +5564,9 @@ export default withEnglishFallback({
fieldPlaceholder: "sahə",
scorePlaceholder: "bal",
pushAction: "Əlavə et",
+ pushSide: "Əlavə etmə mövqeyi",
+ pushSideLeft: "Baş (LPUSH)",
+ pushSideRight: "Quyruq (RPUSH)",
addAction: "Əlavə et",
setAction: "Təyin et",
memberDetail: "Üzvün təfərrüatları",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index d939cfae9c..e64ca9f787 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -6480,6 +6480,9 @@ export default {
fieldPlaceholder: "field",
scorePlaceholder: "score",
pushAction: "Push",
+ pushSide: "Push position",
+ pushSideLeft: "Head (LPUSH)",
+ pushSideRight: "Tail (RPUSH)",
addAction: "Add",
setAction: "Set",
memberDetail: "Member detail",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 708892b3bf..27c43ea201 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -5925,6 +5925,9 @@ export default withEnglishFallback({
fieldPlaceholder: "campo",
scorePlaceholder: "puntuación",
pushAction: "Insertar",
+ pushSide: "Posición de inserción",
+ pushSideLeft: "Inicio (LPUSH)",
+ pushSideRight: "Final (RPUSH)",
addAction: "Añadir",
setAction: "Establecer",
memberDetail: "Detalle del miembro",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 6f3849fa64..cb529b4f96 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -5739,6 +5739,9 @@ export default withEnglishFallback({
fieldPlaceholder: "campo",
scorePlaceholder: "punteggio",
pushAction: "Inserisci",
+ pushSide: "Posizione di inserimento",
+ pushSideLeft: "Testa (LPUSH)",
+ pushSideRight: "Coda (RPUSH)",
addAction: "Aggiungi",
setAction: "Imposta",
memberDetail: "Dettaglio membro",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index bf62d85432..42cf3f31c9 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -5765,6 +5765,9 @@ export default withEnglishFallback({
fieldPlaceholder: "フィールド",
scorePlaceholder: "スコア",
pushAction: "追加",
+ pushSide: "挿入位置",
+ pushSideLeft: "先頭 (LPUSH)",
+ pushSideRight: "末尾 (RPUSH)",
addAction: "追加",
setAction: "設定",
memberDetail: "メンバー詳細",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 27867c1be0..21c376f1df 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -5462,6 +5462,9 @@ export default withEnglishFallback({
fieldPlaceholder: "필드",
scorePlaceholder: "점수",
pushAction: "추가",
+ pushSide: "푸시 위치",
+ pushSideLeft: "머리 (LPUSH)",
+ pushSideRight: "꼬리 (RPUSH)",
addAction: "추가",
setAction: "설정",
memberDetail: "멤버 상세",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index c2c00787b5..6d0073e1ab 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -5739,6 +5739,9 @@ export default withEnglishFallback({
fieldPlaceholder: "campo",
scorePlaceholder: "pontuação",
pushAction: "Inserir",
+ pushSide: "Posição de inserção",
+ pushSideLeft: "Início (LPUSH)",
+ pushSideRight: "Fim (RPUSH)",
addAction: "Adicionar",
setAction: "Definir",
memberDetail: "Detalhe do membro",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index a59e4800d7..1766755307 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -6786,6 +6786,9 @@ export default withEnglishFallback({
fieldPlaceholder: "поле",
scorePlaceholder: "оценка",
pushAction: "Вставить",
+ pushSide: "Позиция добавления",
+ pushSideLeft: "Начало (LPUSH)",
+ pushSideRight: "Конец (RPUSH)",
addAction: "Добавить",
setAction: "Задать",
memberDetail: "Сведения об элементе",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index bf44aaa40a..cc15d5cd7c 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -5458,6 +5458,9 @@ export default withEnglishFallback({
fieldPlaceholder: "alan",
scorePlaceholder: "puan",
pushAction: "Ekle",
+ pushSide: "Ekleme konumu",
+ pushSideLeft: "Baş (LPUSH)",
+ pushSideRight: "Kuyruk (RPUSH)",
addAction: "Ekle",
setAction: "Ayarla",
memberDetail: "Üye ayrıntısı",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index bf7aa5dde9..289d2c489a 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -6470,6 +6470,9 @@ export default withEnglishFallback({
fieldPlaceholder: "字段",
scorePlaceholder: "分值",
pushAction: "推入",
+ pushSide: "推入位置",
+ pushSideLeft: "队头 (LPUSH)",
+ pushSideRight: "队尾 (RPUSH)",
addAction: "添加",
setAction: "设置",
memberDetail: "成员详情",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index e06caec49c..9ed2d4f25d 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -5084,6 +5084,9 @@ export default withEnglishFallback({
fieldPlaceholder: "欄位",
scorePlaceholder: "分數",
pushAction: "推入",
+ pushSide: "推入位置",
+ pushSideLeft: "佇列頭 (LPUSH)",
+ pushSideRight: "佇列尾 (RPUSH)",
addAction: "新增",
setAction: "設定",
memberDetail: "成員詳情",
diff --git a/apps/desktop/src/lib/backend/http.ts b/apps/desktop/src/lib/backend/http.ts
index 5e68d70047..bc7845197e 100644
--- a/apps/desktop/src/lib/backend/http.ts
+++ b/apps/desktop/src/lib/backend/http.ts
@@ -3755,8 +3755,8 @@ export async function redisHashFieldSetExpireAt(connectionId: string, db: number
return post("/api/redis/hash-field-set-expire-at", { connectionId, db, keyRaw, field, expireAt });
}
-export async function redisListPush(connectionId: string, db: number, keyRaw: string, value: string, ttl?: number): Promise<void> {
- return post("/api/redis/list-push", { connectionId, db, keyRaw, value, ttl });
+export async function redisListPush(connectionId: string, db: number, keyRaw: string, value: string, ttl?: number, side?: "left" | "right"): Promise<void> {
+ return post("/api/redis/list-push", { connectionId, db, keyRaw, value, ttl, side });
}
export async function redisListSet(connectionId: string, db: number, keyRaw: string, index: number, value: string): Promise<void> {
diff --git a/apps/desktop/src/lib/backend/tauri.ts b/apps/desktop/src/lib/backend/tauri.ts
index 9e209c805f..596623a43e 100644
--- a/apps/desktop/src/lib/backend/tauri.ts
+++ b/apps/desktop/src/lib/backend/tauri.ts
@@ -3605,8 +3605,8 @@ export async function redisHashFieldSetExpireAt(connectionId: string, db: number
return invoke("redis_hash_field_set_expire_at", { connectionId, db, keyRaw, field, expireAt });
}
-export async function redisListPush(connectionId: string, db: number, keyRaw: string, value: string, ttl?: number): Promise<void> {
- return invoke("redis_list_push", { connectionId, db, keyRaw, value, ttl });
+export async function redisListPush(connectionId: string, db: number, keyRaw: string, value: string, ttl?: number, side?: "left" | "right"): Promise<void> {
+ return invoke("redis_list_push", { connectionId, db, keyRaw, value, ttl, side });
}
export async function redisListSet(connectionId: string, db: number, keyRaw: string, index: number, value: string): Promise<void> {
diff --git a/crates/dbx-core/src/query/redis_ops.rs b/crates/dbx-core/src/query/redis_ops.rs
index adfe7b5fb5..bb3ef77797 100644
--- a/crates/dbx-core/src/query/redis_ops.rs
+++ b/crates/dbx-core/src/query/redis_ops.rs
@@ -5,6 +5,8 @@ use crate::db::redis_driver::{
RedisStreamPendingPage, RedisValue,
};
+pub use redis_driver::ListPushSide;
+
async fn ensure_redis_pool(state: &AppState, connection_id: &str) -> Result<(), String> {
state.get_or_create_pool(connection_id, None).await.map(|_| ())
}
@@ -620,8 +622,9 @@ pub async fn redis_list_push_core(
key: &str,
value: &str,
ttl: Option<i64>,
+ side: redis_driver::ListPushSide,
) -> Result<(), String> {
- redis_list_push_in_db_core(state, connection_id, 0, key, value, ttl).await
+ redis_list_push_in_db_core(state, connection_id, 0, key, value, ttl, side).await
}
pub async fn redis_list_push_in_db_core(
@@ -631,6 +634,7 @@ pub async fn redis_list_push_in_db_core(
key_raw: &str,
value: &str,
ttl: Option<i64>,
+ side: redis_driver::ListPushSide,
) -> Result<(), String> {
ensure_redis_pool(state, connection_id).await?;
let pool = state.pool_handle(connection_id).await.ok_or("Not found")?;
@@ -641,12 +645,12 @@ pub async fn redis_list_push_in_db_core(
RedisConnection::Direct(con) => {
let mut con = con.lock().await;
redis_driver::select_db(&mut *con, db).await?;
- redis_driver::list_push(&mut *con, &key, value, ttl).await
+ redis_driver::list_push(&mut *con, &key, value, ttl, side).await
}
RedisConnection::Cluster(cluster) => {
redis_driver::ensure_cluster_database(cluster, db).await?;
let mut con = redis_driver::cluster_key_connection_in_db(cluster, &key, db).await?;
- redis_driver::list_push(&mut con, &key, value, ttl).await
+ redis_driver::list_push(&mut con, &key, value, ttl, side).await
}
}
}
diff --git a/crates/dbx-core/tests/redis_cluster_databases.rs b/crates/dbx-core/tests/redis_cluster_databases.rs
index e1c3dddd3c..99b49e62cb 100644
--- a/crates/dbx-core/tests/redis_cluster_databases.rs
+++ b/crates/dbx-core/tests/redis_cluster_databases.rs
@@ -162,7 +162,9 @@ async fn core_cluster_database_operations_are_isolated_on_all_masters() {
let key_raw = raw(&key);
match kind {
"hash" => redis_hash_set_in_db_core(state, ID, db, &key_raw, "field", &value, None).await.unwrap(),
- "list" => redis_list_push_in_db_core(state, ID, db, &key_raw, &value, None).await.unwrap(),
+ "list" => redis_list_push_in_db_core(state, ID, db, &key_raw, &value, None, ListPushSide::Right)
+ .await
+ .unwrap(),
"set" => redis_set_add_in_db_core(state, ID, db, &key_raw, &value, None).await.unwrap(),
"zset" => redis_zadd_in_db_core(state, ID, db, &key_raw, &value, 1.0, None).await.unwrap(),
"stream" => redis_stream_add_in_db_core(
diff --git a/crates/dbx-driver-redis/src/lib.rs b/crates/dbx-driver-redis/src/lib.rs
index da996f7911..e89f0acf27 100644
--- a/crates/dbx-driver-redis/src/lib.rs
+++ b/crates/dbx-driver-redis/src/lib.rs
@@ -4180,11 +4180,41 @@ fn is_hash_field_update_cluster_script_rejection(error: &str) -> bool {
detail.contains("bad lua script for redis cluster") && (detail.contains("httl") || detail.contains("hexpire"))
}
-pub async fn list_push<C>(con: &mut C, key: &[u8], value: &str, ttl: Option<i64>) -> Result<(), String>
+/// Which end of a Redis list to push to. `Right` (RPUSH) is the historical
+/// default; `Left` (LPUSH) lets users prepend when using lists as queues.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum ListPushSide {
+ Left,
+ Right,
+}
+
+impl ListPushSide {
+ pub fn from_str_lossy(value: Option<&str>) -> Self {
+ match value.map(str::to_ascii_lowercase).as_deref() {
+ Some("left") => ListPushSide::Left,
+ _ => ListPushSide::Right,
+ }
+ }
+
+ fn command(self) -> &'static str {
+ match self {
+ ListPushSide::Left => "LPUSH",
+ ListPushSide::Right => "RPUSH",
+ }
+ }
+}
+
+pub async fn list_push<C>(
+ con: &mut C,
+ key: &[u8],
+ value: &str,
+ ttl: Option<i64>,
+ side: ListPushSide,
+) -> Result<(), String>
where
C: ConnectionLike + Send + Sync + Unpin,
{
- redis::cmd("RPUSH").arg(key).arg(value).query_async::<()>(con).await.map_err(|e| e.to_string())?;
+ redis::cmd(side.command()).arg(key).arg(value).query_async::<()>(con).await.map_err(|e| e.to_string())?;
apply_expire_if_needed(con, key, ttl).await
}
diff --git a/crates/dbx-web/src/routes/redis.rs b/crates/dbx-web/src/routes/redis.rs
index 898b3f9cf7..f3341bbe3f 100644
--- a/crates/dbx-web/src/routes/redis.rs
+++ b/crates/dbx-web/src/routes/redis.rs
@@ -212,6 +212,7 @@ pub struct RedisListRequest {
pub value: Option<String>,
pub index: Option<i64>,
pub ttl: Option<i64>,
+ pub side: Option<String>,
}
#[derive(Deserialize)]
@@ -651,6 +652,7 @@ pub async fn list_push(
) -> Result<Json<()>, AppError> {
ensure_writable(&state.app, &req.connection_id, "LPUSH").await?;
let value = req.value.as_deref().unwrap_or("");
+ let side = dbx_core::redis_ops::ListPushSide::from_str_lossy(req.side.as_deref());
dbx_core::redis_ops::redis_list_push_in_db_core(
&state.app,
&req.connection_id,
@@ -658,6 +660,7 @@ pub async fn list_push(
&req.key_raw,
value,
req.ttl,
+ side,
)
.await
.map_err(AppError::from)?;
diff --git a/src-tauri/src/commands/redis_cmd.rs b/src-tauri/src/commands/redis_cmd.rs
index 8faf16233c..ecead99083 100644
--- a/src-tauri/src/commands/redis_cmd.rs
+++ b/src-tauri/src/commands/redis_cmd.rs
@@ -288,9 +288,11 @@ pub async fn redis_list_push(
key_raw: String,
value: String,
ttl: Option<i64>,
+ side: Option<String>,
) -> Result<(), String> {
ensure_connection_writable(&state, &connection_id, "LPUSH").await?;
- dbx_core::redis_ops::redis_list_push_in_db_core(&state, &connection_id, db, &key_raw, &value, ttl).await
+ let side = dbx_core::redis_ops::ListPushSide::from_str_lossy(side.as_deref());
+ dbx_core::redis_ops::redis_list_push_in_db_core(&state, &connection_id, db, &key_raw, &value, ttl, side).await
}
#[tauri::command]