MongoDB

Stage 1 · Lesson 3 of 8

BSON and data types

Documents and your setup

MongoDB does not store plain JSON. It stores , a binary form of JSON with more types: 32-bit and 64-bit integers, , for exact decimals, dates, and binary data. JSON has only one number type and no date type, so the extra types matter.

Money belongs in Decimal128, not a double, which cannot hold 0.10 exactly. Timestamps belong in the Date type, not in strings, so they sort and compare correctly. In (the MongoDB shell), a bare number like 5 is stored as a double, so use NumberInt, NumberLong or NumberDecimal when the type matters.

Queries match on type as well as value in some cases, which you will meet in the next stage.

Common trapstoring dates as strings like "12/03/2026", which sort alphabetically and break every range query.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with

  • CourseFree
    MongoDB University

    MongoDB

    Free: start with the introduction to MongoDB and Atlas setup lessons, which use the same sample data

Practise

  • Paste a few documents and a query and run it in the browser, no install needed

Keep handy

  • The mongosh docs: connecting, running scripts and the shell helpers such as show and use

  • The Compass docs for the Schema, Explain Plan and Aggregations tabs you will use later

Also worth your time

Mark this stage as not done?