You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

registry.go 837 B

4 years ago
12345678910111213141516171819202122
  1. package bsonx
  2. import (
  3. "go.mongodb.org/mongo-driver/bson"
  4. "go.mongodb.org/mongo-driver/bson/bsoncodec"
  5. )
  6. // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the
  7. // primitive codecs.
  8. var DefaultRegistry = NewRegistryBuilder().Build()
  9. // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and
  10. // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the
  11. // PrimitiveCodecs type in this package.
  12. func NewRegistryBuilder() *bsoncodec.RegistryBuilder {
  13. rb := bsoncodec.NewRegistryBuilder()
  14. bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb)
  15. bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb)
  16. bson.PrimitiveCodecs{}.RegisterPrimitiveCodecs(rb)
  17. primitiveCodecs.RegisterPrimitiveCodecs(rb)
  18. return rb
  19. }