jefersondaniel/pydantic-mongo

using both _id and id

Closed this issue · 1 comments

Hi, in my app I need to use both id and id_, but by default the package converts all id to id_.

is there a way to overcome this?

Kind of "hacky" but you could use the serialization/deserialization aliases of Pydantic to do this.
For example in your actual pydantic model you define the field "identifier" which you can then serialize to "id".

https://docs.pydantic.dev/latest/concepts/alias/