<aside> π‘ Document β The basic unit of data in MongoDB
</aside>
<aside> π‘ Collection β A grouping of documents
</aside>
<aside> π‘ Database β A container for collections
</aside>
MongoDB documents are displayed in JSON format, but stored in BSON.
BSON can Store β All JSON data types , Dates , Numbers , Object ID's ,And more!
Every document requires anβid field, which acts as a primary key
.
If an inserted document doesn't include the _id
field, MongoDB automatically generates an Objectld
for the _**id**
field.
Documents may contain different fields
Fields may contain different types
{
"_id": ObjectId("60d5ec58f3a3b50ae8d6a2e9"),
"name": "Dev Duo",
"age": 19,
"isStudent": true,
"languages":["C++" , "Java" , "JS" , "React JS"],
"address": {
"city": "Vijayawada",
"state": "Andhra Pradesh"
}
}