- Notifications
You must be signed in to change notification settings - Fork 86
Open
Description
I have this very simple script
// test-json.ts import { Redis } from "@upstash/redis" const db = new Redis({ url: process.env.UPSTASH_REDIS_REST_URL!, token: process.env.UPSTASH_REDIS_REST_TOKEN!, }) async function testStupidJson() { const testKey = "test:issue" await db.json.set(testKey, "$", { name: "Bob", age: 25, tier: "basic", }) console.log("=== READING BACK ===") const obj = await db.json.get(testKey, "$") console.log("Full object:", obj) console.log("=== READING TIER FIELD ===") const tier = await db.json.get(testKey, "$.tier") console.log("Tier field:", tier) console.log("=== UPDATING TIER WITH JSONPATH ===") try { await db.json.set(testKey, "$.tier", "premium") console.log("JSONPath update: SUCCESS") } catch (error) { console.log("JSONPath update: FAILED", error) } console.log("=== READING TIER AFTER UPDATE ===") const newTier = await db.json.get(testKey, "$.tier") console.log("New tier:", newTier) // Clean up await db.del(testKey) } testStupidJson().catch(console.error)If I for example change a number key, e.g. await db.json.set(testKey, "$.age", 1)
It works
I am on the latest version @upstash/redis@1.35.6
Thanks a lot guys!
Metadata
Metadata
Assignees
Labels
No labels