diff options
Diffstat (limited to 'redis/commands')
-rw-r--r-- | redis/commands/json/__init__.py | 1 | ||||
-rw-r--r-- | redis/commands/json/commands.py | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/redis/commands/json/__init__.py b/redis/commands/json/__init__.py index 77fb21c..4f2a0c5 100644 --- a/redis/commands/json/__init__.py +++ b/redis/commands/json/__init__.py @@ -38,6 +38,7 @@ class JSON(JSONCommands): "JSON.GET": self._decode, "JSON.MGET": bulk_of_jsons(self._decode), "JSON.SET": lambda r: r and nativestr(r) == "OK", + "JSON.MSET": lambda r: r and nativestr(r) == "OK", "JSON.MERGE": lambda r: r and nativestr(r) == "OK", "JSON.NUMINCRBY": self._decode, "JSON.NUMMULTBY": self._decode, diff --git a/redis/commands/json/commands.py b/redis/commands/json/commands.py index 5da9245..3b2f2a5 100644 --- a/redis/commands/json/commands.py +++ b/redis/commands/json/commands.py @@ -253,6 +253,26 @@ 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, |