{"id":515,"date":"2018-09-27T11:16:09","date_gmt":"2018-09-27T11:16:09","guid":{"rendered":"http:\/\/blog.amt.in\/?p=515"},"modified":"2018-09-27T11:16:09","modified_gmt":"2018-09-27T11:16:09","slug":"introduction-to-mongodb","status":"publish","type":"post","link":"https:\/\/blog.amt.in\/index.php\/2018\/09\/27\/introduction-to-mongodb\/","title":{"rendered":"Introduction to MongoDB"},"content":{"rendered":"<p>MongoDB\u00c2\u00a0is a\u00c2\u00a0free and open-source\u00c2\u00a0cross-platform\u00c2\u00a0document-oriented database\u00c2\u00a0program. Classified as a\u00c2\u00a0NoSQL\u00c2\u00a0database program, MongoDB uses\u00c2\u00a0JSON-like documents with\u00c2\u00a0schemata. Some of the features are as follows:<\/p>\n<ul>\n<li>MongoDB supports field, range query, and regular expression searches.\u00c2\u00a0Queries can return specific fields of documents and also include user-defined\u00c2\u00a0JavaScript\u00c2\u00a0functions. Queries can also be configured to return a random sample of results of a given size.<\/li>\n<li>MongoDB provides high availability with replica sets.\u00c2\u00a0A replica set consists of two or more copies of the data. Each replica set member may act in the role of primary or secondary replica at any time. All writes and reads are done on the primary replica by default. Secondary replicas maintain a copy of the data of the primary using built-in replication. When a primary replica fails, the replica set automatically conducts an election process to determine which secondary should become the primary. Secondaries can optionally serve read operations, but that data is only eventually consistent by default.<\/li>\n<li>MongoDB scales horizontally using\u00c2\u00a0sharding. The user chooses a shard key, which determines how the data in a collection will be distributed. The data is split into ranges (based on the shard key) and distributed across multiple shards. (A shard is a master with one or more slaves.). Alternatively, the shard key can be hashed to map to a shard \u00e2\u20ac\u201c enabling an even data distribution.MongoDB can run over multiple servers, balancing the load or duplicating data to keep the system up and running in case of hardware failure.<\/li>\n<li>MongoDB can be used as a\u00c2\u00a0file system, called\u00c2\u00a0GridFS, with load balancing and data replication features over multiple machines for storing files.This function, called\u00c2\u00a0grid file system,\u00c2\u00a0is included with MongoDB drivers. MongoDB exposes functions for file manipulation and content to developers. GridFS can be accessed using mongofiles utility or plugins for\u00c2\u00a0Nginx\u00c2\u00a0and\u00c2\u00a0lighttpd.\u00c2\u00a0GridFS divides a file into parts, or chunks, and stores each of those chunks as a separate document.<\/li>\n<li>MongoDB provides three ways to perform aggregation: the aggregation pipeline, the map-reduce function, and single-purpose aggregation methods.Map-reduce\u00c2\u00a0can be used for batch processing of data and aggregation operations. But according to MongoDB&#8217;s documentation, the Aggregation Pipeline provides better performance for most aggregation operations.The aggregation framework enables users to obtain the kind of results for which the\u00c2\u00a0SQL\u00c2\u00a0GROUP BY clause is used. Aggregation operators can be strung together to form a pipeline \u00e2\u20ac\u201c analogous to\u00c2\u00a0Unix pipes. The aggregation framework includes the $lookup operator which can join documents from multiple documents, as well as statistical operators such as standard deviation.<\/li>\n<li>JavaScript can be used in queries, aggregation functions (such as MapReduce), and sent directly to the database to be executed.<\/li>\n<li>MongoDB supports fixed-size collections called capped collections. This type of collection maintains insertion order and, once the specified size has been reached, behaves like a\u00c2\u00a0circular queue.<\/li>\n<li>Support for multi-document\u00c2\u00a0ACID\u00c2\u00a0transactions were added to MongoDB with the General Availability of the 4.0 release in June 2018.<\/li>\n<\/ul>\n<p>The above is a brief about MongoDB. Watch this space for more updates on the latest trends in Technology.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB\u00c2\u00a0is a\u00c2\u00a0free and open-source\u00c2\u00a0cross-platform\u00c2\u00a0document-oriented database\u00c2\u00a0program.<\/p>\n","protected":false},"author":1,"featured_media":519,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[227,229,7],"tags":[228,230,18],"class_list":["post-515","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","category-mongodb","category-techtrends","tag-database","tag-mongodb","tag-technology"],"_links":{"self":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/comments?post=515"}],"version-history":[{"count":3,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/515\/revisions"}],"predecessor-version":[{"id":518,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/posts\/515\/revisions\/518"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media\/519"}],"wp:attachment":[{"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/media?parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/categories?post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.amt.in\/index.php\/wp-json\/wp\/v2\/tags?post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}