1""" 2Various data structures used by chaise. 3""" 4 5importdataclasses 6 7importchaise# Be careful using this, for circular import reasons 8 9
[docs]10@dataclasses.dataclass11classAllDocs_DocRef:12"""13 A document reference returned by :meth:`~chaise.Database.iter_all_docs`14 """1516#: The document ID17docid:str1819#: The revision of the document20rev:str2122_db:"chaise.Database"23_doc:object|None24
[docs]25asyncdefdoc(self):26"""27 Actually get the document. Since docid+rev is roughly immutable, caches28 it.2930 (Might be pre-loaded by the producing function.)31 """32ifself._docisNone:33# docid + revision is immutable(ish), so it's safe to cache34# (It can still be deleted/vacuumed, but that's fine. probably.)35self._doc=awaitself._db.get(self.docid,rev=self.rev)36returnself._doc