@@ -225,12 +225,19 @@ def _ensure_email_lower(self, data: dict[str, Any]) -> None:
225225 if "email" in data and isinstance (data ["email" ], str ):
226226 data ["email" ] = data ["email" ].lower ()
227227
228- async def get (self , id : ID | str ) -> UP | None :
228+ async def get (
229+ self ,
230+ id : ID | str ,
231+ instant_update : bool = False ,
232+ ) -> UP | None :
229233 """Get a user by id and hydrate oauth_accounts if available."""
230234 id_str = self ._ensure_id_str (id )
231235
232236 async with self ._table (self .user_table_name , self ._resource_region ) as table :
233- resp = await table .get_item (Key = {self .primary_key : id_str })
237+ resp = await table .get_item (
238+ Key = {self .primary_key : id_str },
239+ ConsistentRead = instant_update ,
240+ )
234241 item = resp .get ("Item" )
235242 user = self ._item_to_user (item )
236243
@@ -335,11 +342,19 @@ async def create(self, create_dict: dict[str, Any]) -> UP:
335342 raise ValueError ("Could not cast DB item to User model" )
336343 return refreshed_user
337344
338- async def update (self , user : UP , update_dict : dict [str , Any ]) -> UP :
345+ async def update (
346+ self ,
347+ user : UP ,
348+ update_dict : dict [str , Any ],
349+ instant_update : bool = False ,
350+ ) -> UP :
339351 """Update a user with update_dict and return the updated UP instance."""
340352 user_id = self ._extract_id_from_user (user )
341353 async with self ._table (self .user_table_name , self ._resource_region ) as table :
342- resp = await table .get_item (Key = {self .primary_key : user_id })
354+ resp = await table .get_item (
355+ Key = {self .primary_key : user_id },
356+ ConsistentRead = instant_update ,
357+ )
343358 current = resp .get ("Item" , None )
344359
345360 if not current :
@@ -414,7 +429,7 @@ async def update_oauth_account(
414429 user : UP ,
415430 oauth_account : OAP , # type: ignore
416431 update_dict : dict [str , Any ],
417- ) -> UP | None :
432+ ) -> UP :
418433 """Update an OAuth account and return the refreshed user (UP)."""
419434 if self .oauth_account_table is None or self .oauth_account_table_name is None :
420435 raise NotImplementedError ()
0 commit comments