blob: c9ef029d5676ecfd397f7a9d426484a539068f7a [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// 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
7package bson
8
9import "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.
13var 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.
18func 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}