File: bson.md

package info (click to toggle)
python-odmantic 1.0.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,684 kB
  • sloc: python: 8,547; sh: 37; makefile: 34; xml: 13; javascript: 3
file content (28 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
This module provides helpers to build Pydantic Models containing BSON objects.

## Pydantic model helpers

::: odmantic.bson.BaseBSONModel
    selection:
        members:
          -

::: odmantic.bson.BSON_TYPES_ENCODERS

Encoders required to encode BSON fields (can be used in the Pydantic Model's `Config.json_encoders` parameter). See [pydantic: JSON Encoders](https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.json_encoders){:target=blank_} for more details.

## Custom BSON serializer annotation

::: odmantic.bson.WithBsonSerializer


## Pydantic type helpers

Those helpers inherit directly from their respective `bson` types. They add the field
validation logic required by Pydantic to work with them. On top of this, the appropriate JSON schemas are generated for them.

::: odmantic.bson.ObjectId
::: odmantic.bson.Int64
::: odmantic.bson.Decimal128
::: odmantic.bson.Binary
::: odmantic.bson.Regex