Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from .token_escaper import TokenEscaper


__INCOMPLETE = object()
model_registry = {}
_T = TypeVar("_T")
Model = TypeVar("Model", bound="RedisModel")
Expand Down Expand Up @@ -1532,9 +1533,11 @@ async def all_pks(cls): # type: ignore
)

@classmethod
async def get(cls: Type["Model"], pk: Any) -> "Model":
async def get(cls: Type["Model"], pk: Any, default:__INCOMPLETE) -> "Model":
document = await cls.db().hgetall(cls.make_primary_key(pk))
if not document:
if default is not INCOMPLETE:
return default
raise NotFoundError
try:
result = cls.parse_obj(document)
Expand Down