MongoDB Document

MongoDB is a document oriented database and all data is stored in documents. A document is similar to a row in RDBMS. Documents consist of JSON-style (JavaScript Object Notation) field-value pairs and they are stored on the disk in BSON (Binary JSON) serialization format.

Field names are strings and can contain any Unicode character except the . (Dot) character

Field names cannot start with the $ character

The string _id is a reserved name used to denote a primary key and hence cannot be used as field name

The : (colon) character separates the field name from its value

Values can be number, string, boolean, array or any other BSON type

The field value pairs are separated by comma

Every document in MongoDB has a _id field which is the first field in the document. The _id field is unique to a document collection and contain any BSON data type value except an array. If a document is created without an _id field then MongoDB will automatically add the _id field as the first element of the document and assign its ObjectId value to this field.

MongoDB has a size limitation of 16MB for each documents. This is to ensure that a document does not use excessive amount of RAM or bandwidth.