MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / list_collections

Method list_collections

pymongo/synchronous/database.py:1161–1196  ·  view source on GitHub ↗

Get a cursor over the collections of this database. Cursors are closed automatically when they are exhausted (the last batch of data is retrieved from the database). If a cursor is not exhausted, it will be closed automatically upon garbage collection, which leaves resources open bu

(
        self,
        session: Optional[ClientSession] = None,
        filter: Optional[Mapping[str, Any]] = None,
        comment: Optional[Any] = None,
        **kwargs: Any,
    )

Source from the content-addressed store, hash-verified

1159 )
1160
1161 def list_collections(
1162 self,
1163 session: Optional[ClientSession] = None,
1164 filter: Optional[Mapping[str, Any]] = None,
1165 comment: Optional[Any] = None,
1166 **kwargs: Any,
1167 ) -> CommandCursor[MutableMapping[str, Any]]:
1168 """Get a cursor over the collections of this database.
1169
1170 Cursors are closed automatically when they are exhausted (the last batch of data is retrieved from the database).
1171 If a cursor is not exhausted, it will be closed automatically upon garbage collection, which leaves resources open but unused for a potentially long period of time.
1172 To avoid this, best practice is to call :meth:`Cursor.close` when the cursor is no longer needed,
1173 or use the cursor in a with statement::
1174
1175 with database.list_collections() as cursor:
1176 for collection in cursor:
1177 print(collection)
1178
1179 :param session: a
1180 :class:`~pymongo.client_session.ClientSession`.
1181 :param filter: A query document to filter the list of
1182 collections returned from the listCollections command.
1183 :param comment: A user-provided comment to attach to this
1184 command.
1185 :param kwargs: Optional parameters of the
1186 `listCollections command
1187 <https://mongodb.com/docs/manual/reference/command/listCollections/>`_
1188 can be passed as keyword arguments to this method. The supported
1189 options differ by server version.
1190
1191
1192 :return: An instance of :class:`~pymongo.command_cursor.CommandCursor`.
1193
1194 .. versionadded:: 3.6
1195 """
1196 return self._list_collections_helper(session, filter, comment, **kwargs)
1197
1198 def _list_collection_names(
1199 self,

Calls 1