0PricingLogin
MongoDB Academy · Lesson

What Is a BSON Document?

Learners will read and write BSON documents in the MongoDB shell, recognising field types like strings, numbers, arrays, and nested objects.

JSON vs BSON: The Key Difference

You write MongoDB data as familiar JSON, but it's stored as BSON — binary JSON. It's faster to scan and supports richer types like dates and ObjectId.

The Structure of a BSON Document

A BSON document is just key-value pairs in curly braces, like a JS object. Every document needs an _id, and MongoDB auto-creates a unique one if you skip it.

// A minimal MongoDB document
{
  _id: ObjectId('64a2f3b1c9e7e12345678901'),
  name: 'Alice',
  age: 30,
  active: true
}
// _id is auto-generated if omitted on insert
// ObjectId encodes the insert timestamp in its first 4 bytes

All lessons in this course

  1. What Is a BSON Document?
  2. Collections vs SQL Tables
  3. Databases, Collections, and Namespaces
  4. The mongosh Shell Essentials
← Back to MongoDB Academy