Skip to content

Commit 59d0717

Browse files
authored
GODRIVER-3227 Deprecate bson.DefaultRegistry (#1688)
1 parent ad12442 commit 59d0717

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

bson/registry.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@ import (
1010
"go.mongodb.org/mongo-driver/bson/bsoncodec"
1111
)
1212

13-
// DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the
14-
// primitive codecs.
13+
// DefaultRegistry is the default bsoncodec.Registry. It contains the default
14+
// codecs and the primitive codecs.
15+
//
16+
// Deprecated: Use [NewRegistry] to construct a new default registry. To use a
17+
// custom registry when marshaling or unmarshaling, use the "SetRegistry" method
18+
// on an [Encoder] or [Decoder] instead:
19+
//
20+
// dec, err := bson.NewDecoder(bsonrw.NewBSONDocumentReader(data))
21+
// if err != nil {
22+
// panic(err)
23+
// }
24+
// dec.SetRegistry(reg)
25+
//
26+
// See [Encoder] and [Decoder] for more examples.
1527
var DefaultRegistry = NewRegistry()
1628

1729
// NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and
1830
// decoders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the
1931
// PrimitiveCodecs type in this package.
2032
//
21-
// Deprecated: Use NewRegistry instead.
33+
// Deprecated: Use [NewRegistry] instead.
2234
func NewRegistryBuilder() *bsoncodec.RegistryBuilder {
2335
rb := bsoncodec.NewRegistryBuilder()
2436
bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb)

0 commit comments

Comments
 (0)