Skip to main content

MongoDB: Data Types

MongoDB Data Types :

MongoDB stores documents on disk in the BSON serialization format. BSON is a binary representation of JSON documents, though BSON data format provides more data types than JSON.


MinKey (internal type), Null, Numbers (ints, longs, doubles), Symbol, String, Object, Array, BinData, ObjectId, Boolean, Date Timestamp, Regular Expression, 

MaxKey (internal type)


MongoDB Data Types and Corresponding ID Number

 
Type         Description
Double       Represents a float value.
String





BSON strings are UTF-8. In general, drivers for each
programming language convert from the language’s
string format to UTF-8 when serializing and deserializing BSON.
This makes it possible to store most international characters in BSON strings with ease. [1] In addition, MongoDB $regex queries support UTF-8 in the regex string.
ObjectRepresents an embedded document.
ArraySets or lists of values can be represented as arrays:
Binary dataBinary data is a string of arbitrary bytes, it cannot be manipulated from the shell.
Object id   ObjectIds (MongoDB document identifier, equivalent to a Primary key) are: small, likely unique, fast to generate, and ordered. These values consists of 12-bytes, where the first four bytes are a timestamp that reflect the ObjectId’s creation.
BooleanA logical true or false. Use to evaluate whether a condition is true or false
DateBSON Date is a 64-bit integer that represents the number of milliseconds since the Unix epoch (Jan 1, 1970). This results in a representable date range of about 290 million years into the past and future.
NullIt represents both a null value and a nonexistent field.
Regular Expression  RegExp maps directly to a Javascript RegExp
JavaScript    
SymbolNot supported by the shell. If the shell gets a symbol from the database, it will convert it into a string.
JavaScript (with scope)   
32-bit integerNumbers without decimal points will be saved as 32-bit integers.
Timestamp   BSON has a special timestamp type for internal MongoDB use and is not associated with the regular Date type. Timestamp values are a 64 bit value where :
  • the first 32 bits are a time_t value (seconds since the Unix epoch).
  • the second 32 bits are an incrementing ordinal for operations within a given second.
64-bit integerNumbers without a decimal point will be saved and returned as 64-bit integers.
Min keyMinKey compare less than all other possible BSON element values, respectively, and exist primarily for internal use.
Max keyMaxKey compare greater than all other possible BSON element values, respectively, and exist primarily for internal use.

Comments

Popular posts from this blog

MongoDB - Create Database

MongoDB - Create Database If you want to check your databases list, use the command show dbs Your created database (mydb) is not present in list. To display database, you need to insert at least one document into it. MongoDB use DATABASE_NAME is used to create a database. > use database_name

Linked List

Linked List What is LinkedList: A linked list is a linear data structure where each element is a separate object, which is connected together via links. Linked list elements are not stored at contiguous locations.