diff --git a/fastcrud/crud/fast_crud.py b/fastcrud/crud/fast_crud.py index c9f9044..3b6d91e 100644 --- a/fastcrud/crud/fast_crud.py +++ b/fastcrud/crud/fast_crud.py @@ -1358,8 +1358,7 @@ async def update( update(db, {'username': 'new_username'}, id__ne=1, allow_multiple=False) ``` """ - total_count = await self.count(db, **kwargs) - if not allow_multiple and total_count > 1: + if not allow_multiple and (total_count := await self.count(db, **kwargs)) > 1: raise MultipleResultsFound( f"Expected exactly one record to update, found {total_count}." ) @@ -1423,8 +1422,7 @@ async def db_delete( db_delete(db, username='unique_username', allow_multiple=False) ``` """ - total_count = await self.count(db, **kwargs) - if not allow_multiple and total_count > 1: + if not allow_multiple and (total_count := await self.count(db, **kwargs)) > 1: raise MultipleResultsFound( f"Expected exactly one record to delete, found {total_count}." )