def document(self, name: Optional[str] = None) -> DocumentReference:
     collection = get_by_path(self._data, self._path)
     if name is None:
         name = generate_random_string()
     new_path = self._path + [name]
     if name not in collection:
         set_by_path(self._data, new_path, {})
     return DocumentReference(self._data, new_path, parent=self)
示例#2
0
 def document(self, path):
     return DocumentReference(self._data, path, parent=None)