|
|
|
@ -1483,6 +1483,22 @@ class JsonModel(RedisModel, abc.ABC):
|
|
|
|
|
await db.execute_command("JSON.SET", self.key(), ".", self.json())
|
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
async def all_pks(cls): # type: ignore
|
|
|
|
|
key_prefix = cls.make_key(cls._meta.primary_key_pattern.format(pk=""))
|
|
|
|
|
# TODO: We assume the key ends with the default separator, ":" -- when
|
|
|
|
|
# we make the separator configurable, we need to update this as well.
|
|
|
|
|
# ... And probably lots of other places ...
|
|
|
|
|
#
|
|
|
|
|
# TODO: Also, we need to decide how we want to handle the lack of
|
|
|
|
|
# decode_responses=True...
|
|
|
|
|
return (
|
|
|
|
|
key.split(":")[-1]
|
|
|
|
|
if isinstance(key, str)
|
|
|
|
|
else key.decode(cls.Meta.encoding).split(":")[-1]
|
|
|
|
|
async for key in cls.db().scan_iter(f"{key_prefix}*", _type="ReJSON-RL")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
async def update(self, **field_values):
|
|
|
|
|
validate_model_fields(self.__class__, field_values)
|
|
|
|
|
for field, value in field_values.items():
|
|
|
|
|