Replies: 1 comment 4 replies
-
Hi! I have been able to apply this at the database level changing the system of retrieving/generating the database, like this: from motor import AsyncIOMotorClient
from bson.codec_options import CodecOptions
from datetime import timezone
CODEC_OPTIONS = CodecOptions(tz_aware=True, tzinfo=timezone.utc)
client = AsyncIOMotorClient("mongodb://localhost:27017")
db = client.get_database("test_db", codec_options=CODEC_OPTIONS)
await init_beanie(database=db, document_models=...) But it would be nice to have this Maybe the option is already there, hopefully something like this will be documented. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
how to add codec_options to support custom types in mongo?
Example:
`
from bson.codec_options import TypeCodec, CodecOptions, TypeRegistry
class SetCodec(TypeCodec):
set_codec = SetCodec()
type_registry = TypeRegistry([set_codec])
codec_options = CodecOptions(type_registry=type_registry)
client.get_database(name="foobar", codec_options=codec_options)
`
Beta Was this translation helpful? Give feedback.
All reactions