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. See also
BSON Types.

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.

BSON documents may have more than one field with the same name.
Most MongoDB interfaces, however, represent MongoDB
with a structure (e.g. a hash table) that does not support duplicate
field names. If you need to manipulate documents that have more than one
field with the same name, see the driver documentation for your driver.

Some documents created by internal MongoDB processes may have duplicate
fields, but no MongoDB process will ever add duplicate fields to an
existing user document.

The maximum document size helps ensure that a single document cannot
use excessive amount of RAM or, during transmission, excessive amount
of bandwidth. To store documents larger than the maximum size, MongoDB
provides the GridFS API. See mongofiles and the
documentation for your driver for more
information about GridFS.

MongoDB preserves the order of the document fields following write
operations except for the following cases:

The _id field is always the first field in the document.

Updates that include renaming of field names may
result in the reordering of fields in the document.

Changed in version 2.6: Starting in version 2.6, MongoDB actively attempts to preserve the
field order in a document. Before version 2.6, MongoDB did not
actively preserve the order of the fields in a document.

Use your driver’s BSON UUID facility to generate UUIDs. Be aware
that driver implementations may implement UUID serialization and
deserialization logic differently, which may not be fully compatible
with other drivers. See your driver documentation for
information concerning UUID interoperability.

Note

Most MongoDB driver clients will include the _id field and
generate an ObjectId before sending the insert operation to
MongoDB; however, if the client sends a document without an _id
field, the mongod will add the _id field and generate
the ObjectId.