本站源代码
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.

25 lines
1013B

  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. }
上海开阖软件有限公司 沪ICP备12045867号-1