1.

What are the data types in MongoDB?

Answer»

MongoDB supports a wide range of data types as values in documents. Documents in MongoDB are similar to objects in JavaScript. ALONG with JSON’s essential key/value–pair nature, MongoDB adds SUPPORT for a number of additional data types. The common data types in MongoDB are:

  • Null
    {"x" : null}
  • Boolean
    {"x" : true}
  • Number
    {"x" : 4}
  • String
    {"x" : "foobar"}
  • Date
    {"x" : new Date()}
  • Regular EXPRESSION
    {"x" : /foobar/i}
  • Array
    {"x" : ["a", "b", "c"]}
  • Embedded document
    {"x" : {"foo" : "bar"}}
  • OBJECT ID
    {"x" : ObjectId()}
  • Binary Data
    Binary data is a string of arbitrary bytes.
  • Code
    {"x" : function() { /* ... */ }}


Discussion

No Comment Found