1 00:00:02,100 --> 00:00:05,970 Now sometimes you also want to delete all entries in a collection, 2 00:00:06,000 --> 00:00:07,950 you can do this in two ways. 3 00:00:08,160 --> 00:00:13,680 One way is that you simply reach out to the collection and then you execute delete many and you simply 4 00:00:13,680 --> 00:00:16,770 pass an empty pair of curly braces, 5 00:00:16,770 --> 00:00:22,980 this simply is a filter that matches every document in the collection and therefore, if I now hit enter, all 6 00:00:22,980 --> 00:00:24,170 documents are gone. 7 00:00:24,630 --> 00:00:29,720 As you can see, if I find all documents, nothing is returned. 8 00:00:29,920 --> 00:00:37,180 The alternative would be that you of course delete the entire collection. On a collection in the shell 9 00:00:37,180 --> 00:00:37,650 here, 10 00:00:37,780 --> 00:00:45,490 you can call drop. Now important, you as an administrator working with the shell might do that, later when 11 00:00:45,490 --> 00:00:51,770 you build a real application like in our from shell to driver module towards the end of the course, 12 00:00:51,850 --> 00:00:57,970 you will most likely not call drop from within your application code because you rarely have a situation 13 00:00:58,150 --> 00:01:04,840 where your app, your website or whatever you're building should drop an entire collection. Adding collections 14 00:01:04,840 --> 00:01:08,650 and deleting collections typically is more of a sys admin task, 15 00:01:08,650 --> 00:01:10,420 still it's worth knowing how it works. 16 00:01:10,540 --> 00:01:16,510 Well if you execute this, you'll see true if it succeeded and false if it did not, which it did in this 17 00:01:16,510 --> 00:01:19,320 case because I already deleted it. 18 00:01:19,720 --> 00:01:26,720 You can also delete the entire database with drop database, just on the database, so not on users but 19 00:01:26,790 --> 00:01:32,870 drop database, this dropped the user database and automatically gets us out of the database 20 00:01:32,970 --> 00:01:37,920 which is why I can now execute this and well, nothing was dropped because I'm not in a database, 21 00:01:37,980 --> 00:01:41,850 I would have to use a different one to then drop that. 22 00:01:41,880 --> 00:01:43,830 So dropping collections and databases 23 00:01:43,950 --> 00:01:50,490 obviously also gets rid of the data in there but delete one and delete many are the more common methods 24 00:01:50,490 --> 00:01:51,330 you'll use 25 00:01:51,330 --> 00:01:57,510 also in your application side code. And writing queries is all you need to know to find documents you 26 00:01:57,510 --> 00:01:58,460 need to delete.