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

registry.go 1013B

123456789101112131415161718192021222324
  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. package bson
  7. import "go.mongodb.org/mongo-driver/bson/bsoncodec"
  8. // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the
  9. // primitive codecs.
  10. var DefaultRegistry = NewRegistryBuilder().Build()
  11. // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and
  12. // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the
  13. // PrimitiveCodecs type in this package.
  14. func NewRegistryBuilder() *bsoncodec.RegistryBuilder {
  15. rb := bsoncodec.NewRegistryBuilder()
  16. bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb)
  17. bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb)
  18. primitiveCodecs.RegisterPrimitiveCodecs(rb)
  19. return rb
  20. }