Now sometimes you also want to delete all entries in a collection,
you can do this in two ways.
One way is that you simply reach out to the collection and then you execute delete many and you simply
pass an empty pair of curly braces,
this simply is a filter that matches every document in the collection and therefore, if I now hit enter, all
documents are gone.
As you can see, if I find all documents, nothing is returned.
The alternative would be that you of course delete the entire collection. On a collection in the shell
here,
you can call drop. Now important, you as an administrator working with the shell might do that, later when
you build a real application like in our from shell to driver module towards the end of the course,
you will most likely not call drop from within your application code because you rarely have a situation
where your app, your website or whatever you're building should drop an entire collection. Adding collections
and deleting collections typically is more of a sys admin task,
still it's worth knowing how it works.
Well if you execute this, you'll see true if it succeeded and false if it did not, which it did in this
case because I already deleted it.
You can also delete the entire database with drop database, just on the database, so not on users but
drop database, this dropped the user database and automatically gets us out of the database
which is why I can now execute this and well, nothing was dropped because I'm not in a database,
I would have to use a different one to then drop that.
So dropping collections and databases
obviously also gets rid of the data in there but delete one and delete many are the more common methods
you'll use
also in your application side code. And writing queries is all you need to know to find documents you
need to delete.