|
22 | 22 | None null both
|
23 | 23 | bool boolean both
|
24 | 24 | int [#int]_ int32 / int64 py -> bson
|
25 |
| -`bson.int64.Int64` int64 both |
| 25 | +:class:`bson.int64.Int64` int64 both |
26 | 26 | float number (real) both
|
27 | 27 | str string both
|
28 | 28 | list array both
|
29 |
| -dict / `SON` object both |
30 |
| -datetime.datetime [#dt]_ [#dt2]_ date both |
31 |
| -`bson.regex.Regex` regex both |
| 29 | +dict object both |
| 30 | +:class:`~bson.son.SON` object both |
| 31 | +:py:class:`~collections.abc.Mapping` object py -> bson |
| 32 | +:class:`~bson.raw_bson.RawBSONDocument` object both [#raw]_ |
| 33 | +datetime.datetime [#dt]_ [#dt2]_ UTC datetime both |
| 34 | +:class:`~bson.datetime_ms.DatetimeMS` UTC datetime both [#dt3]_ |
| 35 | +:class:`~bson.regex.Regex` regex both |
32 | 36 | compiled re [#re]_ regex py -> bson
|
33 |
| -`bson.binary.Binary` binary both |
34 |
| -`bson.objectid.ObjectId` oid both |
35 |
| -`bson.dbref.DBRef` dbref both |
| 37 | +:class:`~bson.binary.Binary` binary both |
| 38 | +:py:class:`uuid.UUID` [#uuid]_ binary both |
| 39 | +:class:`~bson.objectid.ObjectId` oid both |
| 40 | +:class:`~bson.dbref.DBRef` dbref both |
| 41 | +:class:`~bson.dbref.DBRef` dbpointer bson -> py |
36 | 42 | None undefined bson -> py
|
37 |
| -`bson.code.Code` code both |
| 43 | +:class:`~bson.code.Code` code both |
38 | 44 | str symbol bson -> py
|
39 | 45 | bytes [#bytes]_ binary both
|
| 46 | +:class:`~bson.timestamp.Timestamp` timestamp both |
| 47 | +:class:`~bson.decimal128.Decimal128` decimal128 both |
| 48 | +:class:`~bson.min_key.MinKey` min key both |
| 49 | +:class:`~bson.max_key.MaxKey` max key both |
40 | 50 | ======================================= ============= ===================
|
41 | 51 |
|
42 | 52 | .. [#int] A Python int will be saved as a BSON int32 or BSON int64 depending
|
43 | 53 | on its size. A BSON int32 will always decode to a Python int. A BSON
|
44 | 54 | int64 will always decode to a :class:`~bson.int64.Int64`.
|
45 |
| -.. [#dt] datetime.datetime instances will be rounded to the nearest |
46 |
| - millisecond when saved |
47 |
| -.. [#dt2] all datetime.datetime instances are treated as *naive*. clients |
48 |
| - should always use UTC. |
| 55 | +.. [#raw] Decoding a bson object to :class:`~bson.raw_bson.RawBSONDocument` can be |
| 56 | + optionally configured via :attr:`~bson.codec_options.CodecOptions.document_class`. |
| 57 | +.. [#dt] datetime.datetime instances are encoded with millisecond precision so |
| 58 | + the microsecond field is truncated. |
| 59 | +.. [#dt2] all datetime.datetime instances are encoded as UTC. By default, they |
| 60 | + are decoded as *naive* but timezone aware datetimes are also supported. |
| 61 | + See :doc:`/examples/datetimes` for examples. |
| 62 | +.. [#dt3] To enable decoding a bson UTC datetime to a :class:`~bson.datetime_ms.DatetimeMS` |
| 63 | + instance see :ref:`handling-out-of-range-datetimes`. |
| 64 | +.. [#uuid] For :py:class:`uuid.UUID` encoding and decoding behavior see :doc:`/examples/uuid`. |
49 | 65 | .. [#re] :class:`~bson.regex.Regex` instances and regular expression
|
50 | 66 | objects from ``re.compile()`` are both saved as BSON regular expressions.
|
51 | 67 | BSON regular expressions are decoded as :class:`~bson.regex.Regex`
|
|
0 commit comments