Convert the cursor to a list.
(self, length: Optional[int] = None)
| 1985 | return AsyncGridOut(self._root_collection, file_document=next_file, session=self.session) |
| 1986 | |
| 1987 | async def to_list(self, length: Optional[int] = None) -> list[AsyncGridOut]: |
| 1988 | """Convert the cursor to a list.""" |
| 1989 | if length is None: |
| 1990 | return [x async for x in self] # noqa: C416,RUF100 |
| 1991 | if length < 1: |
| 1992 | raise ValueError("to_list() length must be greater than 0") |
| 1993 | ret = [] |
| 1994 | for _ in range(length): |
| 1995 | ret.append(await self.next()) |
| 1996 | return ret |
| 1997 | |
| 1998 | __anext__ = next |
| 1999 |