As you can see, we implemented the deleteMany method with filter and then returned the whole collection, which is now empty. Executing this query, every document present in the collection “code” will be deleted at once with the Pune as a city.If we want to delete every single document inside a collection, we will pass simply empty filter, which is, ”, meaning it will delete every document that has the city key, matching with the value of Pune. ![]() ![]() We have seen delete document, with single or multiple documents and how to add filters to make sure specific documents are deleted. The syntax for Delete without filter or parameters: Followed by the working of the method, respectively. Refer the below screenshot of help docs on MongoDB Shell:Īs you can see in the above help, both methods take optional parameters. It deletes the total number of records selected.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |