A document is the basic unit of data in MongoDB, and the object-oriented data model lets you structure data to mirror the object models in your codebase, eliminating the object-relational mapping required by relational databases. MongoDB stores records as BSON documents, a binary representation of JSON that contains more data types than JSON. Documents are field-and-value pairs, and a field value can be any BSON type, including embedded documents, arrays, and arrays of documents. Field names are strings: the _id field is reserved as a primary key, and its value must be unique in the collection, is immutable, and may be any type other than an array or regex; if _id contains subfields, their names cannot begin with a dollar sign. Field names cannot contain the null character, and each field name must be unique within a document — duplicate fields are unsupported and cause unexpected CRUD behavior even if an insert appears to succeed; the $objectToArray aggregation operator reveals duplicates. Use dot notation to access array elements by zero-based index and fields of embedded documents. Scope: MongoDB. Reviewed October 4, 2026.
The document data model
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- www.mongodb.com
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.