Skip to content

Commit

Permalink
add optional timeout arg on basic DocumentReference operations
Browse files Browse the repository at this point in the history
  • Loading branch information
thromer committed Jan 16, 2025
1 parent 90bd2b3 commit cfdc79d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mockfirestore/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def read_time(self) -> Timestamp:
timestamp = Timestamp.from_now()
return timestamp

def get(self, field_path: str) -> Any:
def get(self, field_path: str, timeout: float = None) -> Any:
if not self.exists:
return None
else:
Expand All @@ -63,13 +63,13 @@ def __init__(self, data: Store, path: List[str],
def id(self):
return self._path[-1]

def get(self) -> DocumentSnapshot:
def get(self, timeout: float=None) -> DocumentSnapshot:
return DocumentSnapshot(self, get_by_path(self._data, self._path))

def delete(self):
def delete(self, timeout: float=None):
delete_by_path(self._data, self._path)

def set(self, data: Dict, merge=False):
def set(self, data: Dict, merge=False, timeout: float=None):
if merge:
try:
self.update(deepcopy(data))
Expand All @@ -78,7 +78,7 @@ def set(self, data: Dict, merge=False):
else:
set_by_path(self._data, self._path, deepcopy(data))

def update(self, data: Dict[str, Any]):
def update(self, data: Dict[str, Any], timeout: float=None):
document = get_by_path(self._data, self._path)
if document == {}:
raise NotFound('No document to update: {}'.format(self._path))
Expand Down

0 comments on commit cfdc79d

Please sign in to comment.