withCodecRegistry

fun withCodecRegistry(newCodecRegistry: CodecRegistry): MongoCollection<T>

Create a new collection 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 MongoCollection instance with the different codec registry

Parameters

newCodecRegistry

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

See also

CodecRegistries