Documents
A record in MongoDB is a document
, which is a data structure composed of field and value pairs.

-
Field name
Field names are strings. -
The
_id
Field
In MongoDB, each document stored in a collection requires a unique _id field that acts as a primary key. If an inserted document omits the _id field, the MongoDB driver automatically generates an ObjectId for the _id field.
!Note: Documents have dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data.
Collections
MongoDB stores documents in collections
. Collections are analogous to tables in relational databases.

Databases
In MongoDB, databases hold collections of documents.
BSON
MongoDB stores data records as BSON documents. BSON is a binary representation of JSON documents, though it contains more data types than JSON.
read more: BSON types
网友评论