1 // Copyright (C) MongoDB, Inc. 2017-present.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may
4 // not use this file except in compliance with the License. You may obtain
5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6 7 package bson
8 9 import (
10 "go.mongodb.org/mongo-driver/bson/bsoncodec"
11 )
12 13 // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the
14 // primitive codecs.
15 var DefaultRegistry = NewRegistry()
16 17 // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and
18 // decoders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the
19 // PrimitiveCodecs type in this package.
20 //
21 // Deprecated: Use NewRegistry instead.
22 func NewRegistryBuilder() *bsoncodec.RegistryBuilder {
23 rb := bsoncodec.NewRegistryBuilder()
24 bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb)
25 bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb)
26 primitiveCodecs.RegisterPrimitiveCodecs(rb)
27 return rb
28 }
29 30 // NewRegistry creates a new Registry configured with the default encoders and decoders from the
31 // bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the PrimitiveCodecs
32 // type in this package.
33 func NewRegistry() *bsoncodec.Registry {
34 return NewRegistryBuilder().Build()
35 }
36