MongoDB Document

MongoDB Document is an entity in which zero or more ordered field-value pairs are stored.

In comparison to Relational Databases, it is analogous to a record or row in table.

Document in MongoDB follows BSON Specifications. BSON is binary encoded serialization of JSON-like documents. With BSON, MongoDB Documents can be traversed easily. As BSON uses C data types, encoding data to BSON or decoding from BSON is easier in most of the programming languages.

A document can have documents nested in them. MongoDB Documents are the building blocks of a MongoDB Collection.

We shall learn following topics in this tutorial :


MongoDB Document Operations

Following operations could be performed on MongoDB Documents.


Structure of MongoDB Document

Following is structure of a Document in MongoDB:

Document can contain N number of field-value pairs.

The values can have any datatype that is supported by BSON specification.


Simple MongoDB Document

Following is a simple Document with field-value pairs


Sample MongoDB Document

Lets see a Document containing other documents nested in.


Conclusion :

In this MongoDB Tutorial, we have learnt about MongoDB Documents, its structure with samples and the operations that could be performed on them.