What data types does BSON support?
BSON supports an extended set of types compared to JSON. The main ones are:
The basic types
Double, a floating-point numberString, a string (UTF-8)Boolean, a logical type (true/false)Int32,Int64, integersDecimal128, an exact decimal number (e.g. for money)Null, an empty valueArray, an arrayObject, a nested document
The types unique to BSON
ObjectId, a unique document identifier (12 bytes)Date, a date and timeTimestamp, a type used for replication and internal operationsBinary, binary data (e.g. files)Regular Expression, regular expressionsJavaScript, JS code as a valueJavaScript (with scope), JS code plus contextSymbol, a deprecated type similar to a stringMinKeyandMaxKey, internal values used for sortingUndefined, a deprecated type, equivalent to undefined
Summary: BSON supports both ordinary data types (numbers, strings, arrays) and special ones, ObjectId, Date, Binary, Timestamp, and others, which help MongoDB work more efficiently than it would with plain JSON.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.