Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongodb collection drop function #225

Merged

Conversation

synedra
Copy link
Contributor

@synedra synedra commented Feb 28, 2024

Adding a function for a collection to drop itself: collection.drop(COLLECTION_NAME).

Added a test to validate that it's working. It seems like a ddl sort of thing so that's where I put it.

@synedra synedra requested review from hemidactylus and clun February 28, 2024 18:53
@@ -216,6 +216,9 @@ def delete_many(
f"(gotten '${json.dumps(dm_response)}')"
)

def drop(self, name_or_collection: Union[str, AsyncCollection]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a method on "collection", it has no "name_or_collection" argument (see ref), it being implied that the one to drop is self.

note: The Mongo docs use the term "alias" pretty liberally here IMO :D

@@ -445,6 +448,10 @@ async def delete_many(
f"(gotten '${json.dumps(dm_response)}')"
)

async def drop(self, name_or_collection: Union[str, AsyncCollection]) -> None:
return await self._astra_db_collection.astra_db.delete_collection(name_or_collection)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for the async, and incidentally I am surprised if this typechecks ...

@hemidactylus
Copy link
Collaborator

Can you confirm this is subsumed by #231 (as it seems to me?) In that case, please close.

Base automatically changed from pymongo-convergence-m1 to mongodb-database-attributes March 5, 2024 22:08
@synedra synedra merged commit 7f31f55 into mongodb-database-attributes Mar 5, 2024
1 of 2 checks passed
@synedra synedra deleted the mongodb-collection-drop-function branch March 5, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants