MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / list_collection_names

Method list_collection_names

pymongo/synchronous/database.py:1222–1254  ·  view source on GitHub ↗

Get a list of all the collection names in this database. For example, to list all non-system collections:: filter = {"name": {"$regex": r"^(?!system\\.)"}} db.list_collection_names(filter=filter) :param session: a :class:`~pymongo.client_session

(
        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

1220 ]
1221
1222 def list_collection_names(
1223 self,
1224 session: Optional[ClientSession] = None,
1225 filter: Optional[Mapping[str, Any]] = None,
1226 comment: Optional[Any] = None,
1227 **kwargs: Any,
1228 ) -> list[str]:
1229 """Get a list of all the collection names in this database.
1230
1231 For example, to list all non-system collections::
1232
1233 filter = {"name": {"$regex": r"^(?!system\\.)"}}
1234 db.list_collection_names(filter=filter)
1235
1236 :param session: a
1237 :class:`~pymongo.client_session.ClientSession`.
1238 :param filter: A query document to filter the list of
1239 collections returned from the listCollections command.
1240 :param comment: A user-provided comment to attach to this
1241 command.
1242 :param kwargs: Optional parameters of the
1243 `listCollections command
1244 <https://mongodb.com/docs/manual/reference/command/listCollections/>`_
1245 can be passed as keyword arguments to this method. The supported
1246 options differ by server version.
1247
1248
1249 .. versionchanged:: 3.8
1250 Added the ``filter`` and ``**kwargs`` parameters.
1251
1252 .. versionadded:: 3.6
1253 """
1254 return self._list_collection_names(session, filter, comment, **kwargs)
1255
1256 def _drop_helper(
1257 self, name: str, session: Optional[ClientSession] = None, comment: Optional[Any] = None

Calls 1