Don Newton | 379ae25 | 2019-04-01 12:17:06 -0400 | [diff] [blame^] | 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 | |
| 7 | package bson |
| 8 | |
| 9 | import "github.com/mongodb/mongo-go-driver/bson/bsoncodec" |
| 10 | |
| 11 | // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the |
| 12 | // primitive codecs. |
| 13 | var DefaultRegistry = NewRegistryBuilder().Build() |
| 14 | |
| 15 | // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and |
| 16 | // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the |
| 17 | // PrimitiveCodecs type in this package. |
| 18 | func NewRegistryBuilder() *bsoncodec.RegistryBuilder { |
| 19 | rb := bsoncodec.NewRegistryBuilder() |
| 20 | bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb) |
| 21 | bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb) |
| 22 | primitiveCodecs.RegisterPrimitiveCodecs(rb) |
| 23 | return rb |
| 24 | } |