RedisJSON icon indicating copy to clipboard operation
RedisJSON copied to clipboard

RedisJson Rename a Node in the JsonPath

Open Avdiel opened this issue 4 years ago • 2 comments

Hello,

What's the best practice to modify a node name in the path.

E.g: We have a path: $.animals.your.dogs.kuku I would like to rename dogs to cats so the final path would be: $.animals.your.cats.kuku

The problem is we need transaction (for the simplest way), to read the current "tree" under dogs, save it somewhere, SET a copy of that value to "cats" and then delete the dogs node.

The only option I found is using a Lua script in order to have the opration atomic.

I suppose if that would be supported by Redis/RedisJson, it probably would be a single RENAME operation.

Thanks for any guidance on this. Moshe.

Avdiel avatar Sep 15 '22 14:09 Avdiel

ref https://github.com/RedisJSON/RedisJSON/issues/150

gkorland avatar Sep 18 '22 10:09 gkorland

@Avdiel you can also use Redis Transactions see: https://redis.io/docs/manual/transactions/

gkorland avatar Sep 18 '22 10:09 gkorland