Don Newton | 379ae25 | 2019-04-01 12:17:06 -0400 | [diff] [blame^] | 1 | package bsonx |
| 2 | |
| 3 | import ( |
| 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. |
| 10 | var 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. |
| 15 | func 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 | } |