From 96a4789c9548d4c007b5f4927356c0cc1281154d Mon Sep 17 00:00:00 2001 From: etchao Date: Tue, 17 Jan 2023 15:06:00 -0500 Subject: [PATCH] Add equality and hash functions to DocumentReference --- mockfirestore/document.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mockfirestore/document.py b/mockfirestore/document.py index 24aa433..c4e3c2d 100644 --- a/mockfirestore/document.py +++ b/mockfirestore/document.py @@ -59,6 +59,15 @@ def __init__(self, data: Store, path: List[str], self._path = path self.parent = parent + def __hash__(self): + return hash(tuple(self._path)) + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return False + + return self._path == other._path + @property def id(self): return self._path[-1]