BSON is based upon a set of primitive types. These are described here.
In this BSON library we contain a protocol:
BSONPrimitive. This protocol is public and should normally not be implemented on an existing object.
This protocol is here to support all native Swift types that are related to an existing MongoDB type. Examples of this would be
String, but also custom BSON types like
BSONPrimitives are representable as BSON binary data that can be put into the Value position of a(n) (array-)Document.
These primitives also have a typeIdentifier that identifies the type of the binary data.
Adding custom types that does not conform to an unsupported/custom version of the BSON specification will not be deserialized and will result in corrupt data.
The list of BSON Primitives:
- Document (Array and Dictionary)
- Null (not nil)
- Date (from Foundation)
- NSRegularExpression (or RegularExpression on Linux)