The Shape of a Document

The Shape of a Document: Documents: Fields, Values, Quotes and Braces, Arrays and Documents Inside Documents, BSON Types and the _id Field.

Updated

  1. Documents: Fields, Values, Quotes and Braces (Novice): A document is written like a filled-in form, with braces around it, a field name, a colon and a value for each line, commas between them, and quotes around text but not around numbers or true and false; mongosh's errors point at the punctuation that's missing.
  2. Arrays and Documents Inside Documents (Novice): Square brackets hold a list, called an array, such as a recipe's tags; braces inside a document hold a document inside a document, such as its nutrition box; and a list of documents holds the ingredients, each with a name, an amount and a unit.
  3. BSON Types and the _id Field (Apprentice): MongoDB stores documents as BSON, which adds types JSON doesn't have; whole numbers become int and decimals double, money goes in NumberDecimal and dates in ISODate, and every document has an _id, an ObjectId unless you choose your own.