ByteSliceCodecOptions represents all possible options for byte slice encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type ByteSliceCodecOptions struct { EncodeNilAsEmpty *bool // Specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false. }
func ByteSliceCodec() *ByteSliceCodecOptions
ByteSliceCodec creates a new *ByteSliceCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func MergeByteSliceCodecOptions(opts ...*ByteSliceCodecOptions) *ByteSliceCodecOptions
MergeByteSliceCodecOptions combines the given *ByteSliceCodecOptions into a single *ByteSliceCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func (bs *ByteSliceCodecOptions) SetEncodeNilAsEmpty(b bool) *ByteSliceCodecOptions
SetEncodeNilAsEmpty specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.NilByteSliceAsEmpty instead.
EmptyInterfaceCodecOptions represents all possible options for interface{} encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type EmptyInterfaceCodecOptions struct { DecodeBinaryAsSlice *bool // Specifies if Old and Generic type binarys should default to []slice instead of primitive.Binary. Defaults to false. }
func EmptyInterfaceCodec() *EmptyInterfaceCodecOptions
EmptyInterfaceCodec creates a new *EmptyInterfaceCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func MergeEmptyInterfaceCodecOptions(opts ...*EmptyInterfaceCodecOptions) *EmptyInterfaceCodecOptions
MergeEmptyInterfaceCodecOptions combines the given *EmptyInterfaceCodecOptions into a single *EmptyInterfaceCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func (e *EmptyInterfaceCodecOptions) SetDecodeBinaryAsSlice(b bool) *EmptyInterfaceCodecOptions
SetDecodeBinaryAsSlice specifies if Old and Generic type binarys should default to []slice instead of primitive.Binary. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Decoder.BinaryAsSlice instead.
MapCodecOptions represents all possible options for map encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type MapCodecOptions struct { DecodeZerosMap *bool // Specifies if the map should be zeroed before decoding into it. Defaults to false. EncodeNilAsEmpty *bool // Specifies if a nil map should encode as an empty document instead of null. Defaults to false. // Specifies how keys should be handled. If false, the behavior matches encoding/json, where the encoding key type must // either be a string, an integer type, or implement bsoncodec.KeyMarshaler and the decoding key type must either be a // string, an integer type, or implement bsoncodec.KeyUnmarshaler. If true, keys are encoded with fmt.Sprint() and the // encoding key type must be a string, an integer type, or a float. If true, the use of Stringer will override // TextMarshaler/TextUnmarshaler. Defaults to false. EncodeKeysWithStringer *bool }
func MapCodec() *MapCodecOptions
MapCodec creates a new *MapCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func MergeMapCodecOptions(opts ...*MapCodecOptions) *MapCodecOptions
MergeMapCodecOptions combines the given *MapCodecOptions into a single *MapCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func (t *MapCodecOptions) SetDecodeZerosMap(b bool) *MapCodecOptions
SetDecodeZerosMap specifies if the map should be zeroed before decoding into it. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Decoder.ZeroMaps instead.
func (t *MapCodecOptions) SetEncodeKeysWithStringer(b bool) *MapCodecOptions
SetEncodeKeysWithStringer specifies how keys should be handled. If false, the behavior matches encoding/json, where the encoding key type must either be a string, an integer type, or implement bsoncodec.KeyMarshaler and the decoding key type must either be a string, an integer type, or implement bsoncodec.KeyUnmarshaler. If true, keys are encoded with fmt.Sprint() and the encoding key type must be a string, an integer type, or a float. If true, the use of Stringer will override TextMarshaler/TextUnmarshaler. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.StringifyMapKeysWithFmt instead.
func (t *MapCodecOptions) SetEncodeNilAsEmpty(b bool) *MapCodecOptions
SetEncodeNilAsEmpty specifies if a nil map should encode as an empty document instead of null. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.NilMapAsEmpty instead.
SliceCodecOptions represents all possible options for slice encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type SliceCodecOptions struct { EncodeNilAsEmpty *bool // Specifies if a nil slice should encode as an empty array instead of null. Defaults to false. }
func MergeSliceCodecOptions(opts ...*SliceCodecOptions) *SliceCodecOptions
MergeSliceCodecOptions combines the given *SliceCodecOptions into a single *SliceCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func SliceCodec() *SliceCodecOptions
SliceCodec creates a new *SliceCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func (s *SliceCodecOptions) SetEncodeNilAsEmpty(b bool) *SliceCodecOptions
SetEncodeNilAsEmpty specifies if a nil slice should encode as an empty array instead of null. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.NilSliceAsEmpty instead.
StringCodecOptions represents all possible options for string encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type StringCodecOptions struct { DecodeObjectIDAsHex *bool // Specifies if we should decode ObjectID as the hex value. Defaults to true. }
func MergeStringCodecOptions(opts ...*StringCodecOptions) *StringCodecOptions
MergeStringCodecOptions combines the given *StringCodecOptions into a single *StringCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func StringCodec() *StringCodecOptions
StringCodec creates a new *StringCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func (t *StringCodecOptions) SetDecodeObjectIDAsHex(b bool) *StringCodecOptions
SetDecodeObjectIDAsHex specifies if object IDs should be decoded as their hex representation. If false, a string made from the raw object ID bytes will be used. Defaults to true.
Deprecated: Decoding object IDs as raw bytes will not be supported in Go Driver 2.0.
StructCodecOptions represents all possible options for struct encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type StructCodecOptions struct { DecodeZeroStruct *bool // Specifies if structs should be zeroed before decoding into them. Defaults to false. DecodeDeepZeroInline *bool // Specifies if structs should be recursively zeroed when a inline value is decoded. Defaults to false. EncodeOmitDefaultStruct *bool // Specifies if default structs should be considered empty by omitempty. Defaults to false. AllowUnexportedFields *bool // Specifies if unexported fields should be marshaled/unmarshaled. Defaults to false. OverwriteDuplicatedInlinedFields *bool // Specifies if fields in inlined structs can be overwritten by higher level struct fields with the same key. Defaults to true. }
func MergeStructCodecOptions(opts ...*StructCodecOptions) *StructCodecOptions
MergeStructCodecOptions combines the given *StructCodecOptions into a single *StructCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func StructCodec() *StructCodecOptions
StructCodec creates a new *StructCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func (t *StructCodecOptions) SetAllowUnexportedFields(b bool) *StructCodecOptions
SetAllowUnexportedFields specifies if unexported fields should be marshaled/unmarshaled. Defaults to false.
Deprecated: AllowUnexportedFields does not work on recent versions of Go and will not be supported in Go Driver 2.0.
func (t *StructCodecOptions) SetDecodeDeepZeroInline(b bool) *StructCodecOptions
SetDecodeDeepZeroInline specifies if structs should be zeroed before decoding into them. Defaults to false.
Deprecated: DecodeDeepZeroInline will not be supported in Go Driver 2.0.
func (t *StructCodecOptions) SetDecodeZeroStruct(b bool) *StructCodecOptions
SetDecodeZeroStruct specifies if structs should be zeroed before decoding into them. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Decoder.ZeroStructs instead.
func (t *StructCodecOptions) SetEncodeOmitDefaultStruct(b bool) *StructCodecOptions
SetEncodeOmitDefaultStruct specifies if default structs should be considered empty by omitempty. A default struct has all its values set to their default value. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.OmitZeroStruct instead.
func (t *StructCodecOptions) SetOverwriteDuplicatedInlinedFields(b bool) *StructCodecOptions
SetOverwriteDuplicatedInlinedFields specifies if inlined struct fields can be overwritten by higher level struct fields with the same bson key. When true and decoding, values will be written to the outermost struct with a matching key, and when encoding, keys will have the value of the top-most matching field. When false, decoding and encoding will error if there are duplicate keys after the struct is inlined. Defaults to true.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.ErrorOnInlineDuplicates instead.
TimeCodecOptions represents all possible options for time.Time encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type TimeCodecOptions struct { UseLocalTimeZone *bool // Specifies if we should decode into the local time zone. Defaults to false. }
func MergeTimeCodecOptions(opts ...*TimeCodecOptions) *TimeCodecOptions
MergeTimeCodecOptions combines the given *TimeCodecOptions into a single *TimeCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func TimeCodec() *TimeCodecOptions
TimeCodec creates a new *TimeCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func (t *TimeCodecOptions) SetUseLocalTimeZone(b bool) *TimeCodecOptions
SetUseLocalTimeZone specifies if we should decode into the local time zone. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Decoder.UseLocalTimeZone instead.
UIntCodecOptions represents all possible options for uint encoding and decoding.
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
type UIntCodecOptions struct { EncodeToMinSize *bool // Specifies if all uints except uint64 should be decoded to minimum size bsontype. Defaults to false. }
func MergeUIntCodecOptions(opts ...*UIntCodecOptions) *UIntCodecOptions
MergeUIntCodecOptions combines the given *UIntCodecOptions into a single *UIntCodecOptions in a last one wins fashion.
Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a single options struct instead.
func UIntCodec() *UIntCodecOptions
UIntCodec creates a new *UIntCodecOptions
Deprecated: Use the bson.Encoder and bson.Decoder configuration methods to set the desired BSON marshal and unmarshal behavior instead.
func (u *UIntCodecOptions) SetEncodeToMinSize(b bool) *UIntCodecOptions
SetEncodeToMinSize specifies if all uints except uint64 should be decoded to minimum size bsontype. Defaults to false.
Deprecated: Use go.mongodb.org/mongo-driver/bson.Encoder.IntMinSize instead.