fix: only list authorized collections when listing MongoDB collections (#3888)
This commit is contained in:
@@ -51,7 +51,7 @@ class MongoDB(VectorStoreBase):
|
|||||||
"""Create new collection with vector search index."""
|
"""Create new collection with vector search index."""
|
||||||
try:
|
try:
|
||||||
database = self.client[self.db_name]
|
database = self.client[self.db_name]
|
||||||
collection_names = database.list_collection_names()
|
collection_names = database.list_collection_names(authorizedCollections=True)
|
||||||
if self.collection_name not in collection_names:
|
if self.collection_name not in collection_names:
|
||||||
logger.info(f"Collection '{self.collection_name}' does not exist. Creating it now.")
|
logger.info(f"Collection '{self.collection_name}' does not exist. Creating it now.")
|
||||||
collection = database[self.collection_name]
|
collection = database[self.collection_name]
|
||||||
@@ -240,7 +240,7 @@ class MongoDB(VectorStoreBase):
|
|||||||
List[str]: List of collection names.
|
List[str]: List of collection names.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
collections = self.db.list_collection_names()
|
collections = self.db.list_collection_names(authorizedCollections=True)
|
||||||
logger.info(f"Listing collections in database '{self.db_name}': {collections}")
|
logger.info(f"Listing collections in database '{self.db_name}': {collections}")
|
||||||
return collections
|
return collections
|
||||||
except PyMongoError as e:
|
except PyMongoError as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user