-
Type: New Feature
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
According to theĀ Enumerate Collections Spec, both list_collections and list_collection_names "MUST allow a filter to be passed to include only requested collections".
I noticed this while reviewing https://github.com/mongodb/mongo-python-driver/pull/401. In this PR, we would like to change this line in the docs to use the new list_collection_names:
>>> db.collection_names(include_system_collections=False) [u'posts']
However, db.list_collection_names() will not have the same behavior because it will include system collections. According to the spec we should support this:
>>> db.list_collection_names(filter={"name": {"$regex": r"^(?!system\.)"}}) [u'posts']
Supporting "filter" will also aid users who are migrating from collection_names to list_collection_names.