1""" 2Various data structures used by chaise. 3""" 4 5importdataclasses 6importenum 7importfunctools 8importoperator 910importchaise# Be careful using this, for circular import reasons1112
[docs]13@dataclasses.dataclass14classAllDocs_DocRef:15"""16 A document reference returned by :meth:`~chaise.Database.iter_all_docs`17 """1819#: The document ID20docid:str2122#: The revision of the document23rev:str2425_db:"chaise.Database"26_doc:object|None27
[docs]28asyncdefdoc(self):29"""30 Actually get the document. Since docid+rev is roughly immutable, caches31 it.3233 (Might be pre-loaded by the producing function.)34 """35ifself._docisNone:36# docid + revision is immutable(ish), so it's safe to cache37# (It can still be deleted/vacuumed, but that's fine. probably.)38self._doc=awaitself._db.get(self.docid,rev=self.rev)39returnself._doc
[docs]47@dataclasses.dataclass48classIndexDef:49"""50 Index Definition.51 """5253#: Fields and their direction.54fields:dict[str,AscDesc]
5556
[docs]57@dataclasses.dataclass58classIndex:59"""60 Return of :meth:`~chaise.Database.iter_indexes`61 """6263#: ID of the design document the index belongs to.64ddoc:str65#: Name of the index.66name:str67#: Partitioned (:const:`True`) or global (:const:`False`) index.68partitioned:bool69#: Type of the index. Currently ``"json"`` is the only supported type.70type:str71#: Definition of the index, containing the indexed fields and the sort72#: order: ascending or descending.73def_:IndexDef74