<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":4083,"date":"2022-04-04T11:13:57","date_gmt":"2022-04-04T11:13:57","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=4083"},"modified":"2022-04-04T11:13:57","modified_gmt":"2022-04-04T11:13:57","slug":"what-are-the-data-types-in-mongodb","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/","title":{"rendered":"What are the data types in MongoDB ?"},"content":{"rendered":"<ul>\n<li>The documents are stores in BSON, which is the binary encoded format of JSON in MongoDB.<\/li>\n<li>In MongoDB we can make remote procedure calls using BSON.<\/li>\n<li>BSON data format supports various data-types.<\/li>\n<li>There are various datatypes used in MongoDB.<\/li>\n<\/ul>\n<h4 id=\"null\"><strong>Null :<\/strong><\/h4>\n<ul>\n<li>It is used to store Null values.<\/li>\n<\/ul>\n<p><strong>\u00a0Syntax<\/strong><strong>:\u00a0 <\/strong>{\u201cx\u201d: null}<strong>\u00a0\u00a0\u00a0\u00a0\u00a0<\/strong><\/p>\n<h4 id=\"boolean\"><strong>Boolean :<\/strong><\/h4>\n<ul>\n<li>It is used to store whether true or false.<\/li>\n<\/ul>\n<p><strong>\u00a0 Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: true}<\/p>\n<h4 id=\"integer\"><strong>Integer :<\/strong><\/h4>\n<ul>\n<li>It is used to store an integer value.<\/li>\n<li>In two forms we can store integer data type 32 -bit signed integer and 64 \u2013 bit signed integer.<\/li>\n<\/ul>\n<p><strong>Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: 4}<\/p>\n<h4 id=\"string\"><strong>String :<\/strong><\/h4>\n<ul>\n<li>It is used to store data and the most commonly used data type in MongoDB, BSON strings are of UTF-8.<\/li>\n<li>In each programming language, the drivers convert from the string format of the language to UTF-8 while serializing and deserializing BSON.<\/li>\n<\/ul>\n<p><strong>Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: \u201cfoobar\u201d}<\/p>\n<h4 id=\"date\"><strong>Date :<\/strong><\/h4>\n<ul>\n<li>It is used to store date, and it is a 64-bit integer that represents the number of milliseconds.<\/li>\n<li>It is signed and the BSON data type generally supports UTC datetime.<\/li>\n<li>If the value of the date data type is negative, then it represents the dates before 1970.<\/li>\n<li>In this type, there are various type:<\/li>\n<\/ul>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Date ()<\/li>\n<li>New Date ()<\/li>\n<li>New ISO Date ()<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong>Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: \u201cnew Date ()\u201d}<\/p>\n<h4 id=\"regular-expression\"><strong>Regular expression :<\/strong><\/h4>\n<ul>\n<li>It is used to store regular expressions.<\/li>\n<\/ul>\n<p><strong>Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: \/foobar\/i ()\u201d}<\/p>\n<h4 id=\"array\"><strong>Array :<\/strong><\/h4>\n<ul>\n<li>It is the set of values and stores the same or different data types values in it.<\/li>\n<li>The array is created using square brackets ([]) in MongoDB.<\/li>\n<\/ul>\n<p><strong>Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: [&#8220;a&#8221;, &#8220;b&#8221;, &#8220;c&#8221;]}<\/p>\n<h4 id=\"object-id\"><strong>Object ID :<\/strong><\/h4>\n<ul>\n<li>MongoDB automatically creates a unique\u00a0object ID Whenever we create a new document in the collection.<\/li>\n<li>In MongoDB, there is an _id field\u00a0for each document.<\/li>\n<li>The data stored in Id is length is 12 bytes and it is in hexadecimal format.<\/li>\n<\/ul>\n<p><strong>Syntax<\/strong><strong>: <\/strong>{\u201cx\u201d: objectId ()}<\/p>\n<h4 id=\"binary-data\"><strong>Binary Data :<\/strong><\/h4>\n<ul>\n<li>It is used to store binary data. It is a string of arbitrary bytes.<\/li>\n<\/ul>\n<h4 id=\"code\"><strong>Code :<\/strong><\/h4>\n<ul>\n<li>The string data type is similar to this data.<\/li>\n<li>Mongo shell is generally not supported in this.<\/li>\n<li>If the shell gets a symbol from the database, then it converts this type into a string type.<\/li>\n<\/ul>\n<p><strong>Syntax:<\/strong> {\u201cx\u201d: function() { \/* \u2026*\/ }}<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The documents are stores in BSON, which is the binary encoded format of JSON in MongoDB. In MongoDB we can make remote procedure calls using BSON. BSON data format supports various data-types. There are various datatypes used in MongoDB. Null : It is used to store Null values. \u00a0Syntax:\u00a0 {\u201cx\u201d: null}\u00a0\u00a0\u00a0\u00a0\u00a0 Boolean : It is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[16831],"tags":[16878,16877,16879,16883,16884,16882,16886,16876,16881,16885,16880],"class_list":["post-4083","post","type-post","status-publish","format-standard","hentry","category-mongodb","tag-bson-types","tag-datatypes-in-mongodb","tag-introduction-to-mongodb-data-types","tag-mongodb-data-types-date","tag-mongodb-data-types-size","tag-mongodb-data-types-with-example","tag-mongodb-data-types-with-examples","tag-mongodb-datatypes","tag-mongodb-field-types","tag-mongodb-integer-type","tag-what-are-the-data-types-in-mongodb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What are the data types in MongoDB ? - Mongodb Interview Questions<\/title>\n<meta name=\"description\" content=\"What are the data types in MongoDB ? - Mongodb Interview Questions - The documents are stores in BSON, which is the binary encoded format of JSON 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:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What are the data types in MongoDB ? - Mongodb Interview Questions\" \/>\n<meta property=\"og:description\" content=\"What are the data types in MongoDB ? - Mongodb Interview Questions - The documents are stores in BSON, which is the binary encoded format of JSON in MongoDB.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-04T11:13:57+00:00\" \/>\n<meta name=\"author\" content=\"webmaster\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"webmaster\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/\",\"name\":\"What are the data types in MongoDB ? - Mongodb Interview Questions\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"datePublished\":\"2022-04-04T11:13:57+00:00\",\"dateModified\":\"2022-04-04T11:13:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\"},\"description\":\"What are the data types in MongoDB ? - Mongodb Interview Questions - The documents are stores in BSON, which is the binary encoded format of JSON in MongoDB.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4\",\"name\":\"webmaster\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g\",\"caption\":\"webmaster\"},\"sameAs\":[\"https:\/\/www.wikitechy.com\/interview-questions\"],\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What are the data types in MongoDB ? - Mongodb Interview Questions","description":"What are the data types in MongoDB ? - Mongodb Interview Questions - The documents are stores in BSON, which is the binary encoded format of JSON 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:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/","og_locale":"en_US","og_type":"article","og_title":"What are the data types in MongoDB ? - Mongodb Interview Questions","og_description":"What are the data types in MongoDB ? - Mongodb Interview Questions - The documents are stores in BSON, which is the binary encoded format of JSON in MongoDB.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/","og_site_name":"Wikitechy","article_published_time":"2022-04-04T11:13:57+00:00","author":"webmaster","twitter_card":"summary_large_image","twitter_misc":{"Written by":"webmaster","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/","name":"What are the data types in MongoDB ? - Mongodb Interview Questions","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"datePublished":"2022-04-04T11:13:57+00:00","dateModified":"2022-04-04T11:13:57+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4"},"description":"What are the data types in MongoDB ? - Mongodb Interview Questions - The documents are stores in BSON, which is the binary encoded format of JSON in MongoDB.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/mongodb\/what-are-the-data-types-in-mongodb\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/f785ba3ecc599133e65ab6138042a3e4","name":"webmaster","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/155b77fd8cdda3d0913fcb7e7ee63543b0c345d2d8f6dcebda5b0583ab61f967?s=96&d=mm&r=g","caption":"webmaster"},"sameAs":["https:\/\/www.wikitechy.com\/interview-questions"],"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/webmaster\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=4083"}],"version-history":[{"count":1,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4083\/revisions"}],"predecessor-version":[{"id":4084,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/4083\/revisions\/4084"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=4083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=4083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=4083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}