## Document Format 

MongoDB stores documents on disk in the BSON serialization format. BSON is a binary representation of JSON documents, though it contains more data types than JSON. For the BSON spec, see bsonspec.org$^{13}$. See also BSON Types (page 178). 

The mongo JavaScript shell and the MongoDB language drivers translate between BSON and the language- specific document representation. 

## Document Structure 

MongoDB documents are composed of field-and-value pairs and have the following structure: 

{ field1: value1, field2: value2, field3: value3, ... fieldN: valueN } 

The value of a field can be any of the BSON data types (page 178), including other documents, arrays, and arrays of documents. The following document contains values of varying types: 

var mydoc = { _id: ObjectId("5099803df3f4948bd2f98391"), name: { first: "Alan", last: "Turing" }, birth: new Date('Jun 23, 1912'), death: new Date('Jun 07, 1954'), contribs: [ "Turing machine", "Turing test", "Turingery" ], views : NumberLong(1250000) } 

The above fields have the following data types: 

• _id holds an ObjectId . 

• name holds an embedded document that contains the fields first and last . 

• birth and death hold values of the Date type. 

• contribs holds an array of strings . 

• views holds a value of the NumberLong type. 

## Field Names 

Field names are strings. 

Documents (page 168) have the following restrictions on field names: 

• The field name _id is reserved for use as a primary key; its value must be unique in the collection, is immutable, and may be of any type other than an array. 

• The field names cannot start with the dollar sign ( $ ) character. 

• The field names cannot contain the dot ( . ) character. 

• The field names cannot contain the null character. 

