blob: 83dfaa55d2299aff0a19bccc0def89836599e77a [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001package bsonx
2
3import (
4 "github.com/mongodb/mongo-go-driver/bson"
5 "github.com/mongodb/mongo-go-driver/bson/bsoncodec"
6)
7
8// DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the
9// primitive codecs.
10var DefaultRegistry = NewRegistryBuilder().Build()
11
12// NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and
13// deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the
14// PrimitiveCodecs type in this package.
15func NewRegistryBuilder() *bsoncodec.RegistryBuilder {
16 rb := bsoncodec.NewRegistryBuilder()
17 bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb)
18 bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb)
19 bson.PrimitiveCodecs{}.RegisterPrimitiveCodecs(rb)
20 primitiveCodecs.RegisterPrimitiveCodecs(rb)
21 return rb
22}