Adds delete function at a class level.
This commit is contained in:
parent
2be01743a3
commit
885b24b35b
3 changed files with 38 additions and 0 deletions
|
@ -1335,6 +1335,10 @@ class HashModel(RedisModel, abc.ABC):
|
|||
result = cls.parse_obj(document)
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
async def delete(cls, pk: Any) -> int:
|
||||
return await cls.db().delete(cls.make_primary_key(pk))
|
||||
|
||||
@classmethod
|
||||
@no_type_check
|
||||
def _get_value(cls, *args, **kwargs) -> Any:
|
||||
|
@ -1503,6 +1507,10 @@ class JsonModel(RedisModel, abc.ABC):
|
|||
raise NotFoundError
|
||||
return cls.parse_raw(document)
|
||||
|
||||
@classmethod
|
||||
async def delete(cls, pk: Any) -> int:
|
||||
return await cls.db().delete(cls.make_primary_key(pk))
|
||||
|
||||
@classmethod
|
||||
def redisearch_schema(cls):
|
||||
key_prefix = cls.make_key(cls._meta.primary_key_pattern.format(pk=""))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue