{"id":48431,"date":"2017-07-10T11:00:23","date_gmt":"2017-07-10T08:00:23","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=48431"},"modified":"2023-08-03T10:44:24","modified_gmt":"2023-08-03T07:44:24","slug":"mongodb-collection-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/","title":{"rendered":"MongoDB Collection Example"},"content":{"rendered":"<p>Hello, in this tutorial we will see a study and understand the implementation of the collection in MongoDB. The idea is to understand how MongoDB works and deploy a highly scalable and performance-oriented database.<\/p>\n<h2>1. Introduction<\/h2>\n<p>MongoDB is a document-oriented NoSQL database used for high volume data storage and provides high performance, high availability and automatic scaling.<\/p>\n<h3>1.1 What is MongoDB?<\/h3>\n<ol>\n<li>MongoDB is a <em>document database<\/em> where each database contains <strong>collections<\/strong> which in turn contains <strong>documents<\/strong>. Each document can be different with varying number of fields. The size and content of each document can be different from each other and stored in a JSON-like format, <a href=\"https:\/\/en.wikipedia.org\/wiki\/BSON\" target=\"_blank\" rel=\"noopener\">Binary JSON (BSN)<\/a> in MongoDB<\/li>\n<li>The rows (or the documents as called in MongoDB) doesn\u2019t need to have a schema defined beforehand. Instead, the fields can be created on the fly<\/li>\n<li>Data model available within MongoDB allows developers to represent hierarchical relationships, store arrays, and other more complex structures more easily<\/li>\n<li>MongoDB environments offers scalability<\/li>\n<\/ol>\n<h3>1.2 What is NoSQL?<\/h3>\n<p>NoSQL Database is used to refer a non-SQL or non-relational database concepts.<\/p>\n<ol>\n<li>Provides a mechanism for storage and retrieval of data other than tabular relations model used in relational databases<\/li>\n<li>Provides more flexibility since all records are not restricted to the same column names and types defined across the entire table<\/li>\n<li>Do not use SQL language to query data and provides <strong>no<\/strong> strict schema<\/li>\n<li>With NoSQL, ACID (Atomicity, Consistency, Isolation, Durability) properties of database transactions are not guaranteed<\/li>\n<li>Offers scalability and high performance for handling huge volumes of data<\/li>\n<\/ol>\n<h3>1.3 Why to use MongoDB?<\/h3>\n<p>Below are some of the reasons why someone should start using MongoDB:<\/p>\n<ol>\n<li><strong>Document-oriented<\/strong>: Since MongoDB is a NoSQL type database, instead of having data in a relational type format, it stores the data in documents. Thus, making MongoDB very flexible<\/li>\n<li><strong>Ad hoc queries<\/strong>: MongoDB supports searching by field, range queries, and regular expressions searches. It often provides queries to return specific fields within documents<\/li>\n<li><strong>Indexing<\/strong>: Indexes can be created to improve the performance of searches within MongoDB<\/li>\n<li><strong>Automatic Load Balancing<\/strong>: MongoDB uses the concept of sharding to scale horizontally by splitting data across multiple MongoDB instances<\/li>\n<li><strong>Replication<\/strong>: MongoDB can provide high availability with replica sets<\/li>\n<\/ol>\n<h3>1.4 Advantages Over RDBMS<\/h3>\n<p>Below are some of the key term differences between MongoDB and RDBMS:<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>RDBMS<\/strong><\/td>\n<td><strong>MongoDB<\/strong><\/td>\n<td><strong>Difference<\/strong><\/td>\n<\/tr>\n<tr>\n<td>Table<\/td>\n<td>Collection<\/td>\n<td>In RDBMS, the table contains the columns and rows which are used to store the data whereas, in MongoDB, this same structure is known as a collection. The collection contains documents which in turn contains Fields, which in turn are key-value pairs<\/td>\n<\/tr>\n<tr>\n<td>Row<\/td>\n<td>Document<\/td>\n<td>In RDBMS, the row represents a single, implicitly structured data item in a table. In MongoDB, the data is stored in documents<\/td>\n<\/tr>\n<tr>\n<td>Column<\/td>\n<td>Field<\/td>\n<td>In RDBMS, the column denotes a set of data values. These in MongoDB are known as Fields<\/td>\n<\/tr>\n<tr>\n<td>Joins<\/td>\n<td>Embedded documents<\/td>\n<td>In RDBMS, data is sometimes spread across various tables and in order to show a complete view of all data, a join is sometimes formed across tables to get the data. In MongoDB, the data is normally stored in a single collection, but separated by using embedded documents. So there is no concept of joins in MongoDB<\/td>\n<\/tr>\n<tr>\n<td>Primary Key<\/td>\n<td>_id<\/td>\n<td>In MongoDB, the primary key is automatically set to the _id field<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Apart from the terms differences, a few other differences are shown below:<\/p>\n<ol>\n<li>Relational databases are known for enforcing data integrity. This is not an explicit requirement in MongoDB<\/li>\n<li>RDBMS requires that data be <a href=\"http:\/\/beginnersbook.com\/2015\/05\/normalization-in-dbms\/\" target=\"_blank\" rel=\"noopener\">normalized<\/a> first so that it can prevent orphan records and duplicates, thus resulting in more table joins and requiring more keys and indexes. This leads to performance issues which again is not an explicit requirement in MongoDB<\/li>\n<\/ol>\n<h3>1.5 Download and Install MongoDB<\/h3>\n<p>You can watch <a href=\"https:\/\/www.youtube.com\/watch?v=1uFY60CESlM\" target=\"_blank\" rel=\"noopener\">this<\/a> video in order to download and install the MongoDB database on your Windows operating system.<\/p>\n<p>Now, open up the MongoDB workbench and let\u2019s start building the collection in a NoSQL database!<\/p>\n<h2>2. MongoDB Collection Example<\/h2>\n<p>As stated earlier, in MongoDB a database is used to store collections, and each collection is used to store documents. Lets dive in on how to create your first database and collection.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<h3>2.1 Creating a MongoDB Database<\/h3>\n<p>There is no <code>CREATE DATABASE<\/code> statement in MongoDB like there is in <a href=\"https:\/\/www.w3schools.com\/sql\/sql_create_db.asp\" target=\"_blank\" rel=\"noopener\">SQL<\/a>. To create a database we need to use the <code>use<\/code>\u00a0command\u00a0as shown below:<\/p>\n<p><figure id=\"attachment_48432\" aria-describedby=\"caption-attachment-48432\" style=\"width: 528px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48432\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-1.jpg\" alt=\"Fig. 1: MongoDB Database Creation Command\" width=\"528\" height=\"148\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-1.jpg 528w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-1-300x84.jpg 300w\" sizes=\"(max-width: 528px) 100vw, 528px\" \/><\/a><figcaption id=\"caption-attachment-48432\" class=\"wp-caption-text\">Fig. 1: MongoDB Database Creation Command<\/figcaption><\/figure><\/p>\n<p><strong>Note:<\/strong> If the database already exists, a new one will not be created!<\/p>\n<p>Upon successful execution, the following output is shown:<\/p>\n<p><figure id=\"attachment_48433\" aria-describedby=\"caption-attachment-48433\" style=\"width: 569px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48433\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-2.jpg\" alt=\"Fig. 2: MongoDB Database Creation Output\" width=\"569\" height=\"172\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-2.jpg 569w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-2-300x91.jpg 300w\" sizes=\"(max-width: 569px) 100vw, 569px\" \/><\/a><figcaption id=\"caption-attachment-48433\" class=\"wp-caption-text\">Fig. 2: MongoDB Database Creation Output<\/figcaption><\/figure><\/p>\n<p><strong>Note<\/strong>: We get switched to the newly created database automatically.<\/p>\n<h3>2.2 Creating a MongoDB Collection<\/h3>\n<p>A MongoDB <strong>collection<\/strong> is a grouping of MongoDB <em>documents<\/em>. A collection is the equivalent of a table which is created in any other RDMS such as Oracle or MySQL. A collection exists within a single database and doesn&#8217;t enforce any sort of structure.<\/p>\n<h4>2.2.1 Two Ways to Create a Collection<\/h4>\n<p>Here are two ways of creating collections:<\/p>\n<ul>\n<li>Developers can also create a collection explicitly, using the <code>createCollection()<\/code> method<\/li>\n<li>Developers can create a collection on the fly when inserting a document (using the <code>insert()<\/code>) method<\/li>\n<\/ul>\n<p><strong>Using the createCollection() Method<\/strong><\/p>\n<p>Developers can also create collections using the <code>createCollection()<\/code> method. This allows you to create a collection <em>without<\/em> inserting a document. Here is an example of using the <code>createCollection()<\/code> method:<\/p>\n<p><figure id=\"attachment_48434\" aria-describedby=\"caption-attachment-48434\" style=\"width: 538px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48434\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-3.jpg\" alt=\"Fig. 3: MongoDB Create Collection Command\" width=\"538\" height=\"161\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-3.jpg 538w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-3-300x90.jpg 300w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/a><figcaption id=\"caption-attachment-48434\" class=\"wp-caption-text\">Fig. 3: MongoDB Create Collection Command<\/figcaption><\/figure><\/p>\n<p>If the command is executed successfully, the following output will be shown:<\/p>\n<p><figure id=\"attachment_48435\" aria-describedby=\"caption-attachment-48435\" style=\"width: 466px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-4.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48435\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-4.jpg\" alt=\"Fig. 4: MongoDB Creation Collection Output\" width=\"466\" height=\"165\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-4.jpg 466w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-4-300x106.jpg 300w\" sizes=\"(max-width: 466px) 100vw, 466px\" \/><\/a><figcaption id=\"caption-attachment-48435\" class=\"wp-caption-text\">Fig. 4: MongoDB Creation Collection Output<\/figcaption><\/figure><\/p>\n<p>Developers can also specify <strong>options<\/strong> keyword for the collection by using the <code>db.createCollection(name, options)<\/code> syntax. Here is an example:<\/p>\n<p><figure id=\"attachment_48436\" aria-describedby=\"caption-attachment-48436\" style=\"width: 676px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48436\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-5.jpg\" alt=\"Fig. 5: MongoDB Creation Collection with Options Command\" width=\"676\" height=\"121\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-5.jpg 676w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-5-300x54.jpg 300w\" sizes=\"(max-width: 676px) 100vw, 676px\" \/><\/a><figcaption id=\"caption-attachment-48436\" class=\"wp-caption-text\">Fig. 5: MongoDB Creation Collection with Options Command<\/figcaption><\/figure><\/p>\n<p>If the command is executed successfully, the following output will be shown:<\/p>\n<p><figure id=\"attachment_48437\" aria-describedby=\"caption-attachment-48437\" style=\"width: 663px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48437\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-6.jpg\" alt=\"Fig. 6: MongoDB Creation Collection with Options Output\" width=\"663\" height=\"124\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-6.jpg 663w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-6-300x56.jpg 300w\" sizes=\"(max-width: 663px) 100vw, 663px\" \/><\/a><figcaption id=\"caption-attachment-48437\" class=\"wp-caption-text\">Fig. 6: MongoDB Creation Collection with Options Output<\/figcaption><\/figure><\/p>\n<p>The <strong>options<\/strong> fields available as of MongoDB version 3.2 are as follows:<\/p>\n<table>\n<tbody>\n<tr>\n<th>Field<\/th>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<tr>\n<td><strong>capped<\/strong><\/td>\n<td>boolean<\/td>\n<td>When set to <code>true<\/code>, creates a capped collection. A capped collection is a fixed-sized collection that automatically overwrites its oldest entries when it reaches its maximum size. If you specify <code>true<\/code>, you must also set a maximum size in the <code>size<\/code> field<\/td>\n<\/tr>\n<tr>\n<td><strong>autoIndexId<\/strong><\/td>\n<td>boolean<\/td>\n<td>Specify <code>false<\/code> to disable the automatic creation of an index on the <code>_id<\/code> field. As of MongoDB version 3.2, this field is deprecated, and it will be removed in version 3.4<\/td>\n<\/tr>\n<tr>\n<td><strong>size<\/strong><\/td>\n<td>number<\/td>\n<td>Maximum size in bytes for a capped collection. Only used with capped collections (it is ignored in other collections)<\/td>\n<\/tr>\n<tr>\n<td><strong>max<\/strong><\/td>\n<td>number<\/td>\n<td>Maximum number of documents allowed in the capped collection. Note that the <code>size<\/code> field takes precedence over the <code>max<\/code> field. If the collection reaches its size limit before the document limit has been reached, MongoDB will remove documents anyway<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Using the insert() Method<\/strong><\/p>\n<p>A very convenient method for creating a collection is to directly insert a document into one. If it does not exist, a new one will be created automatically as shown in the example code below:<\/p>\n<p><figure id=\"attachment_48438\" aria-describedby=\"caption-attachment-48438\" style=\"width: 658px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-7.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48438\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-7.jpg\" alt=\"Fig. 7: MongoDB Create Collection Using Insert Command\" width=\"658\" height=\"136\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-7.jpg 658w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-7-300x62.jpg 300w\" sizes=\"(max-width: 658px) 100vw, 658px\" \/><\/a><figcaption id=\"caption-attachment-48438\" class=\"wp-caption-text\">Fig. 7: MongoDB Create Collection Using Insert Command<\/figcaption><\/figure><\/p>\n<p><strong>Notes<\/strong>:<\/p>\n<ul>\n<li><code>db.painters<\/code> We define the collection (regardless if it exists) to add documents to.<\/li>\n<li>We use the <em>insert statement<\/em> to insert a document into the predefined <code>painters<\/code> collection.<\/li>\n<li>We directly define document data in the form of comma separated name\/value pairs.<\/li>\n<\/ul>\n<p>Upon successful execution, the following output is shown:<\/p>\n<p><figure id=\"attachment_48439\" aria-describedby=\"caption-attachment-48439\" style=\"width: 665px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-8.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48439\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-8.jpg\" alt=\"Fig. 8: MongoDB Creation Collection Using Insert Output\" width=\"665\" height=\"145\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-8.jpg 665w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-8-300x65.jpg 300w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><\/a><figcaption id=\"caption-attachment-48439\" class=\"wp-caption-text\">Fig. 8: MongoDB Creation Collection Using Insert Output<\/figcaption><\/figure><\/p>\n<p><code>WriteResult({ \"nInserted\" : 1 })<\/code> dictates that a write operation was executed, and that a single record was inserted into the newly created <code>painters<\/code> collection.<\/p>\n<p>The <strong>insert<\/strong> command can also be used to insert multiple documents into a collection at one time. The below code example can be used to insert multiple documents at a time. The following example shows how this can be done:<\/p>\n<ul>\n<li>Create a JavaScript variable called <code>myGuitarist<\/code> to hold the array of documents<\/li>\n<li>Add the required documents with the Field Name and values to the variable<\/li>\n<li>Use the insert command to insert the array of documents into the collection<\/li>\n<\/ul>\n<p><figure id=\"attachment_48440\" aria-describedby=\"caption-attachment-48440\" style=\"width: 777px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-9.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48440\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-9.jpg\" alt=\"Fig. 9: MongoDB Create Collection Using Array\" width=\"777\" height=\"165\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-9.jpg 777w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-9-300x64.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-9-768x163.jpg 768w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/a><figcaption id=\"caption-attachment-48440\" class=\"wp-caption-text\">Fig. 9: MongoDB Create Collection Using Array<\/figcaption><\/figure><\/p>\n<p>If the command is executed successfully, the following output will be shown:<\/p>\n<p><figure id=\"attachment_48441\" aria-describedby=\"caption-attachment-48441\" style=\"width: 772px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-10.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48441\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-10.jpg\" alt=\"Fig. 10: MongoDB Create Collection Using Array Output\" width=\"772\" height=\"285\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-10.jpg 772w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-10-300x111.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-10-768x284.jpg 768w\" sizes=\"(max-width: 772px) 100vw, 772px\" \/><\/a><figcaption id=\"caption-attachment-48441\" class=\"wp-caption-text\">Fig. 10: MongoDB Create Collection Using Array Output<\/figcaption><\/figure><\/p>\n<h3>2.3 Show MongoDB Collections<\/h3>\n<p>To <strong>check the created collection<\/strong>, use the command <code>show collections<\/code>. Here is an example:<\/p>\n<p><figure id=\"attachment_48442\" aria-describedby=\"caption-attachment-48442\" style=\"width: 770px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-11.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48442\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-11.jpg\" alt=\"Fig. 11: Show MongoDB Collections\" width=\"770\" height=\"343\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-11.jpg 770w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-11-300x134.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-11-768x342.jpg 768w\" sizes=\"(max-width: 770px) 100vw, 770px\" \/><\/a><figcaption id=\"caption-attachment-48442\" class=\"wp-caption-text\">Fig. 11: Show MongoDB Collections<\/figcaption><\/figure><\/p>\n<h3>2.4 Drop MongoDB Collections<\/h3>\n<p>In MongoDB, <code>db.collection_name.drop()<\/code> method is used to drop a collection from the database. It completely removes a collection from the database and does not leave any indexes associated with the dropped collections.<\/p>\n<p>The <code>db.collection_name.drop()<\/code> method does not take any argument and produce an error when it is called with an argument. Here is an example:<\/p>\n<p><figure id=\"attachment_48443\" aria-describedby=\"caption-attachment-48443\" style=\"width: 772px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-12.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48443\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-12.jpg\" alt=\"Fig. 12: Drop MongoDB Collection\" width=\"772\" height=\"358\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-12.jpg 772w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-12-300x139.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-12-768x356.jpg 768w\" sizes=\"(max-width: 772px) 100vw, 772px\" \/><\/a><figcaption id=\"caption-attachment-48443\" class=\"wp-caption-text\">Fig. 12: Drop MongoDB Collection<\/figcaption><\/figure><\/p>\n<p>Now, check the collections in the database.<\/p>\n<p><figure id=\"attachment_48444\" aria-describedby=\"caption-attachment-48444\" style=\"width: 774px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-13.jpg\"><img decoding=\"async\" class=\"size-full wp-image-48444\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-13.jpg\" alt=\"Fig. 13: Show MongoDB Collections after Drop Function\" width=\"774\" height=\"408\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-13.jpg 774w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-13-300x158.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/07\/mongodb-collection-guide-13-768x405.jpg 768w\" sizes=\"(max-width: 774px) 100vw, 774px\" \/><\/a><figcaption id=\"caption-attachment-48444\" class=\"wp-caption-text\">Fig. 13: Show MongoDB Collections after Drop Function<\/figcaption><\/figure><\/p>\n<p><strong>Note<\/strong>: The <em>drop<\/em> command returns true if it successfully drops a collection. It returns false when there is no existing collection to drop.<\/p>\n<h2>3. Conclusion<\/h2>\n<p>The main goal of this article is to discuss the MongoDB features and an introduction to MongoDB Collections. Overall speaking, I found MongoDB very powerful and easy to use. I look forward to using MongoDB with Node.js and will share my experience in future blogs.<\/p>\n<h2>4. Download the MongoDB Files<\/h2>\n<p>This was an example of MongoDB Collection. Run the script and the result will be printed in the console window.<\/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\/2017\/07\/MongoDB-Collection-Example.zip\" target=\"_blank\" rel=\"noopener\"><strong>MongoDB Collection Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello, in this tutorial we will see a study and understand the implementation of the collection in MongoDB. The idea is to understand how MongoDB works and deploy a highly scalable and performance-oriented database. 1. Introduction MongoDB is a document-oriented NoSQL database used for high volume data storage and provides high performance, high availability and &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-48431","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 Collection Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Hello, in this tutorial we will see a study and understand the implementation of collection in MongoDB.The idea behind is to understand how MongoDB works.\" \/>\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-collection-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MongoDB Collection Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Hello, in this tutorial we will see a study and understand the implementation of collection in MongoDB.The idea behind is to understand how MongoDB works.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-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=\"2017-07-10T08:00:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-03T07:44:24+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=\"10 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-collection-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/\"},\"author\":{\"name\":\"Yatin\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13\"},\"headline\":\"MongoDB Collection Example\",\"datePublished\":\"2017-07-10T08:00:23+00:00\",\"dateModified\":\"2023-08-03T07:44:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/\"},\"wordCount\":1598,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-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-collection-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/\",\"name\":\"MongoDB Collection Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg\",\"datePublished\":\"2017-07-10T08:00:23+00:00\",\"dateModified\":\"2023-08-03T07:44:24+00:00\",\"description\":\"Hello, in this tutorial we will see a study and understand the implementation of collection in MongoDB.The idea behind is to understand how MongoDB works.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-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-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 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 Collection Example - Java Code Geeks","description":"Hello, in this tutorial we will see a study and understand the implementation of collection in MongoDB.The idea behind is to understand how MongoDB works.","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-collection-example\/","og_locale":"en_US","og_type":"article","og_title":"MongoDB Collection Example - Java Code Geeks","og_description":"Hello, in this tutorial we will see a study and understand the implementation of collection in MongoDB.The idea behind is to understand how MongoDB works.","og_url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-07-10T08:00:23+00:00","article_modified_time":"2023-08-03T07:44:24+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":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/"},"author":{"name":"Yatin","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/9874407a37b028e8be3276e2b5960d13"},"headline":"MongoDB Collection Example","datePublished":"2017-07-10T08:00:23+00:00","dateModified":"2023-08-03T07:44:24+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/"},"wordCount":1598,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-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-collection-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/","url":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/","name":"MongoDB Collection Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/04\/mongodb-logo.jpg","datePublished":"2017-07-10T08:00:23+00:00","dateModified":"2023-08-03T07:44:24+00:00","description":"Hello, in this tutorial we will see a study and understand the implementation of collection in MongoDB.The idea behind is to understand how MongoDB works.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-collection-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/software-development\/mongodb\/mongodb-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-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 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\/48431","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=48431"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/48431\/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=48431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=48431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=48431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}