def get(self, pk): ds = self.db.collection('users').document(str(pk)).get() if not ds.exists: raise ObjectDoesNotExist("Object does not exist") data = ds.to_dict() data['store'] = self return User.from_dict(data)
def get(self, pk): try: with open(self.filename, 'r') as f: data = json.load(f) except FileNotFoundError: raise ObjectDoesNotExist() data['store'] = self return User.from_dict(data)
def all(self): for document_snapshot in self.db.collection('users').stream(): data = document_snapshot.to_dict() data['store'] = self yield User.from_dict(data)