withCodecRegistry

fun withCodecRegistry(newCodecRegistry: CodecRegistry): MongoDatabase

Create a new MongoDatabase instance with a different codec registry.

The CodecRegistry configured by this method is effectively treated by the driver as an instance of org.bson.codecs.configuration.CodecProvider, which CodecRegistry extends. So there is no benefit to defining a class that implements CodecRegistry. Rather, an application should always create CodecRegistry instances using the factory methods in org.bson.codecs.configuration.CodecRegistries.

Return

a new MongoDatabase instance with the different codec registry

Parameters

newCodecRegistry

the new org.bson.codecs.configuration.CodecRegistry for the database

See also

CodecRegistries