summaryrefslogtreecommitdiff
path: root/redis/commands/json/commands.py
diff options
context:
space:
mode:
authorshacharPash <shachar.pashchur@redis.com>2023-05-15 17:07:46 +0300
committershacharPash <shachar.pashchur@redis.com>2023-05-15 17:07:46 +0300
commitd690e179fe8f7684ca0c19faf5585d7bd44a3b83 (patch)
tree8f67c0c5dbb13ef60948a461879e7222ff5033ca /redis/commands/json/commands.py
parent5dc0be3040e6ffe9a0505c9f9d1bb721f152a85c (diff)
downloadredis-py-d690e179fe8f7684ca0c19faf5585d7bd44a3b83.tar.gz
Support JSON.MSET command
Diffstat (limited to 'redis/commands/json/commands.py')
-rw-r--r--redis/commands/json/commands.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py
index 5da9245..42e3ef2 100644
--- a/redis/commands/json/commands.py
+++ b/redis/commands/json/commands.py
@@ -253,6 +253,25 @@ class JSONCommands:
pieces.append("XX")
return self.execute_command("JSON.SET", *pieces)
+ def mset(self, name: str, path: str, obj: JsonType, *items) -> Optional[str]:
+ """
+ Set the JSON value at key ``name`` under the ``path`` to ``obj`` for one or more keys.
+ ``items`` accepts a list of additional key/path/value to set.
+
+ For the purpose of using this within a pipeline, this command is also
+ aliased to JSON.MSET.
+
+ For more information see `JSON.MSET <https://redis.io/commands/json.mset>`_.
+ """
+
+ pieces = [name, path, self._encode(obj)]
+
+ for key, path, value in zip(*[iter(items)] * 3):
+ pieces.extend([key, path, self._encode(value)])
+
+ return self.execute_command("JSON.MSET", *pieces)
+
+
def merge(
self,
name: str,