{"id":55406,"date":"2018-02-15T15:00:42","date_gmt":"2018-02-15T13:00:42","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=55406"},"modified":"2018-02-15T13:29:03","modified_gmt":"2018-02-15T11:29:03","slug":"mongodb-delete-collection-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/","title":{"rendered":"MongoDB Delete Collection Example"},"content":{"rendered":"<p>Hello readers, in this tutorial, we will see how to <em>delete<\/em> a collection in MongoDB. Let&#8217;s study in brief the different ways in which a MongoDB collection can be deleted.<\/p>\n<h2>1. Introduction<\/h2>\n<p>If you have installed the MongoDB application on Windows or Ubuntu operating system and you wish to learn about the delete operations then follow the below steps. It&#8217;s very simple to use these utilities, but before moving further let&#8217;s take a look at MongoDB.<\/p>\n<h3>1.1 What is MongoDB?<\/h3>\n<ul>\n<li>MongoDB is a high-performance <em>NoSQL database<\/em> where each database has collections which in turn has documents. Each document has a different number of fields, size, content, and is stored in a JSON-like format (i.e. Binary JSON (<a href=\"https:\/\/en.wikipedia.org\/wiki\/BSON\" target=\"_blank\" rel=\"noopener\">BSN<\/a>)<\/li>\n<li>The documents in MongoDB doesn\u2019t need to have a schema defined beforehand. Instead, the fields (i.e. <em>records<\/em>) can be created on the go<\/li>\n<li>Data model available within the MongoDB allows developers to represent the hierarchical relationships, store arrays, and other more complex structures easily<\/li>\n<li>This NoSQL solution often comes with embedding, auto-sharding, and onboard replication for better scalability and high availability<\/li>\n<\/ul>\n<h2>2. MongoDB Delete Collection Example<\/h2>\n<p>In this tutorial, we will go through the different methods to drop\/delete a collection in a Mongo database.<\/p>\n<h3>2.1 db.collection.remove()<\/h3>\n<p>In Mongo database, this method either deletes all documents from a collection or a single document that matches a specified condition. Here is what the syntax will look like.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Syntax<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.collection_name.remove(Deletion_Criteria, &lt;Optional_Parameter&gt;)\r\n<\/pre>\n<p>where:<\/p>\n<ul>\n<li><strong>Deletion_Criteria<\/strong> is the condition on which the document has to be deleted<\/li>\n<li><strong>Optional_Parameter<\/strong> is a boolean value which when set to <code>true<\/code> or <code>1<\/code>, deletes only a single document<\/li>\n<\/ul>\n<p>Let&#8217;s understand this with the help of an example.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.inventory.remove({})\r\n<\/pre>\n<p>This command will drop <em>all<\/em> documents from the <code>inventory<\/code> collection as shown below.<\/p>\n<p><figure id=\"attachment_55407\" aria-describedby=\"caption-attachment-55407\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55407\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-1.jpg\" alt=\"Fig. 1: Remove all documents\" width=\"849\" height=\"173\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-1.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-1-300x61.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-1-768x156.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55407\" class=\"wp-caption-text\">Fig. 1: Remove all documents<\/figcaption><\/figure><\/p>\n<p>Do <strong>note<\/strong>, if developers want to remove a <em>single<\/em> document that matches the given criteria, then developers can use the following syntax.<\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.inventory.remove( { status : \"A\" }, 1 )\r\n<\/pre>\n<p>The modified command accepts an optional parameter along with the deletion criteria and will remove a single document from the <code>inventory<\/code> collection.<\/p>\n<p><figure id=\"attachment_55408\" aria-describedby=\"caption-attachment-55408\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55408\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-2.jpg\" alt=\"Fig. 2: Remove single document\" width=\"849\" height=\"135\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-2.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-2-300x48.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-2-768x122.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55408\" class=\"wp-caption-text\">Fig. 2: Remove single document<\/figcaption><\/figure><\/p>\n<h3>2.2 db.collection.deleteOne()<\/h3>\n<p>This method was introduced in 3.2 version and drop at most a single document that matches the specified condition even though many documents may match the specified filter. Here is what the syntax will look like.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Syntax<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.collection_name.deleteOne(Deletion_Criteria)\r\n<\/pre>\n<p>This method is similar to the <code> db.inventory.remove()<\/code> method with the optional parameter set to <em>true<\/em> or <em>1<\/em>. Let&#8217;s understand this function with the help of an example.<\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.inventory.deleteOne( { status: \"D\" } )\r\n<\/pre>\n<p>This command will drop the <em>first<\/em> record that matches the specified condition.<\/p>\n<p><figure id=\"attachment_55409\" aria-describedby=\"caption-attachment-55409\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55409\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-3.jpg\" alt=\"Fig. 3: Delete first record\" width=\"849\" height=\"141\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-3.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-3-300x50.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-3-768x128.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55409\" class=\"wp-caption-text\">Fig. 3: Delete the first record<\/figcaption><\/figure><\/p>\n<h3>2.3 db.collection.deleteMany()<\/h3>\n<p>This method was again introduced in 3.2 version and deletes all documents that match the specified criteria. Here is what the syntax will look like.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Syntax<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.collection_name.deleteMany(Deletion_Criteria)\r\n<\/pre>\n<p>Let&#8217;s understand this with the help of an example.<\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.inventory.deleteMany({})\r\n<\/pre>\n<p>This command will drop <em>all<\/em> documents from the <code>inventory<\/code> collection.<\/p>\n<p><figure id=\"attachment_55410\" aria-describedby=\"caption-attachment-55410\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55410\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-4.jpg\" alt=\"Fig. 4: Delete multiple documents\" width=\"849\" height=\"149\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-4.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-4-300x53.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-4-768x135.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55410\" class=\"wp-caption-text\">Fig. 4: Delete multiple documents<\/figcaption><\/figure><\/p>\n<p>Do <strong>note<\/strong>, if developers want to remove all documents that match the specified criteria, they can use the following syntax.<\/p>\n<pre class=\"brush:bash;wrap-lines:false;\">&gt; db.inventory.deleteMany({status : \"A\" })\r\n<\/pre>\n<p><figure id=\"attachment_55411\" aria-describedby=\"caption-attachment-55411\" style=\"width: 849px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-55411\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-5.jpg\" alt=\"Fig. 5: Delete selective documents\" width=\"849\" height=\"240\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-5.jpg 849w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-5-300x85.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/mongodb-dc-project-guide-5-768x217.jpg 768w\" sizes=\"(max-width: 849px) 100vw, 849px\" \/><\/a><figcaption id=\"caption-attachment-55411\" class=\"wp-caption-text\">Fig. 5: Delete selective documents<\/figcaption><\/figure><\/p>\n<p>That\u2019s all for this post. Happy Learning!!<\/p>\n<h2>3. Conclusion<\/h2>\n<p>In this tutorial, we learned about the delete collection feature of the MongoDB. Developers can download the sample commands in the <a href=\"#projectDownload\">Downloads<\/a> section.<\/p>\n<h2><a name=\"projectDownload\"><\/a>4. Download the Eclipse Project<\/h2>\n<p>This was an example of a <em>delete<\/em> operation in the Mongo database.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/02\/MongoDbDeleteCollectionEx.zip\" target=\"_blank\" rel=\"noopener\"><strong>MongoDbDeleteCollectionEx<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello readers, in this tutorial, we will see how to delete a collection in MongoDB. Let&#8217;s study in brief the different ways in which a MongoDB collection can be deleted. 1. Introduction If you have installed the MongoDB application on Windows or Ubuntu operating system and you wish to learn about the delete operations then &hellip;<\/p>\n","protected":false},"author":119,"featured_media":36154,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1447],"tags":[1194],"class_list":["post-55406","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mongodb","tag-mongodb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MongoDB Delete Collection Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hello readers, in this tutorial, we will see how to delete a collection in MongoDB.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MongoDB Delete Collection Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hello readers, in this tutorial, we will see how to delete a collection in MongoDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-15T13:00:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Yatin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Yatin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"MongoDB Delete Collection Example\",\"datePublished\":\"2018-02-15T13:00:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\"},\"wordCount\":598,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"keywords\":[\"MongoDb\"],\"articleSection\":[\"MongoDB\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\",\"name\":\"MongoDB Delete Collection Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"datePublished\":\"2018-02-15T13:00:42+00:00\",\"description\":\"Hello readers, in this tutorial, we will see how to delete a collection in MongoDB.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Software Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MongoDB\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/software-development\/mongodb\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"MongoDB Delete Collection Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\",\"name\":\"Yatin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg\",\"caption\":\"Yatin\"},\"description\":\"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MongoDB Delete Collection Example - Java Code Geeks","description":"Hello readers, in this tutorial, we will see how to delete a collection in MongoDB.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/","og_locale":"en_US","og_type":"article","og_title":"MongoDB Delete Collection Example - Java Code Geeks","og_description":"Hello readers, in this tutorial, we will see how to delete a collection in MongoDB.","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-02-15T13:00:42+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","type":"image\/jpeg"}],"author":"Yatin","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Yatin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"MongoDB Delete Collection Example","datePublished":"2018-02-15T13:00:42+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/"},"wordCount":598,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","keywords":["MongoDb"],"articleSection":["MongoDB"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/","name":"MongoDB Delete Collection Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","datePublished":"2018-02-15T13:00:42+00:00","description":"Hello readers, in this tutorial, we will see how to delete a collection in MongoDB.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-delete-collection-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Software Development","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/"},{"@type":"ListItem","position":3,"name":"MongoDB","item":"https:\/\/examples.javacodegeeks.com\/category\/software-development\/mongodb\/"},{"@type":"ListItem","position":4,"name":"MongoDB Delete Collection Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13","name":"Yatin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2023\/09\/cropped-Yatin-Batra_avatar_1515758148-96x96.jpg","caption":"Yatin"},"description":"An experience full-stack engineer well versed with Core Java, Spring\/Springboot, MVC, Security, AOP, Frontend (Angular &amp; React), and cloud technologies (such as AWS, GCP, Jenkins, Docker, K8).","sameAs":["https:\/\/www.javacodegeeks.com"],"url":"https:\/\/examples.javacodegeeks.com\/author\/yatin-batra\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/119"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=55406"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/55406\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/36154"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=55406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=55406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=55406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}