bsonoptions

package
v1.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 0 Imported by: 35

Documentation

Overview

Package bsonoptions defines the optional configurations for the BSON codecs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSliceCodecOptions deprecated added in v1.3.0

type ByteSliceCodecOptions struct {
	EncodeNilAsEmpty *bool // Specifies if a nil byte slice should encode as an empty binary instead of null. Defaults to false.
}

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.

func ByteSliceCodec deprecated added in v1.3.0

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 deprecated added in v1.3.0

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 (*ByteSliceCodecOptions) SetEncodeNilAsEmpty deprecated added in v1.3.0

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.

type EmptyInterfaceCodecOptions deprecated added in v1.3.0

type EmptyInterfaceCodecOptions struct {
	DecodeBinaryAsSlice *bool // Specifies if Old and Generic type binarys should default to []slice instead of primitive.Binary. Defaults to false.
}

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.

func EmptyInterfaceCodec deprecated added in v1.3.0

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 deprecated added in v1.3.0

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 (*EmptyInterfaceCodecOptions) SetDecodeBinaryAsSlice deprecated added in v1.3.0

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.

type MapCodecOptions deprecated

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
}

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.

func MapCodec deprecated

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 deprecated

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 (*MapCodecOptions) SetDecodeZerosMap deprecated

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 (*MapCodecOptions) SetEncodeKeysWithStringer deprecated added in v1.4.0

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 (*MapCodecOptions) SetEncodeNilAsEmpty deprecated added in v1.3.0

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.

type SliceCodecOptions deprecated added in v1.3.0

type SliceCodecOptions struct {
	EncodeNilAsEmpty *bool // Specifies if a nil slice should encode as an empty array instead of null. Defaults to false.
}

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.

func MergeSliceCodecOptions deprecated added in v1.3.0

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 deprecated added in v1.3.0

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 (*SliceCodecOptions) SetEncodeNilAsEmpty deprecated added in v1.3.0

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.

type StringCodecOptions deprecated

type StringCodecOptions struct {
	DecodeObjectIDAsHex *bool // Specifies if we should decode ObjectID as the hex value. Defaults to true.
}

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.

func MergeStringCodecOptions deprecated

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 deprecated

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 (*StringCodecOptions) SetDecodeObjectIDAsHex deprecated

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.

type StructCodecOptions deprecated

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.
}

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.

func MergeStructCodecOptions deprecated

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 deprecated

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 (*StructCodecOptions) SetAllowUnexportedFields deprecated

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 (*StructCodecOptions) SetDecodeDeepZeroInline deprecated

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 (*StructCodecOptions) SetDecodeZeroStruct deprecated

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 (*StructCodecOptions) SetEncodeOmitDefaultStruct deprecated

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 (*StructCodecOptions) SetOverwriteDuplicatedInlinedFields deprecated added in v1.4.4

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.

type TimeCodecOptions deprecated

type TimeCodecOptions struct {
	UseLocalTimeZone *bool // Specifies if we should decode into the local time zone. Defaults to false.
}

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.

func MergeTimeCodecOptions deprecated

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 deprecated

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 (*TimeCodecOptions) SetUseLocalTimeZone deprecated

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.

type UIntCodecOptions deprecated added in v1.3.0

type UIntCodecOptions struct {
	EncodeToMinSize *bool // Specifies if all uints except uint64 should be decoded to minimum size bsontype. Defaults to false.
}

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.

func MergeUIntCodecOptions deprecated added in v1.3.0

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 deprecated added in v1.3.0

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 (*UIntCodecOptions) SetEncodeToMinSize deprecated added in v1.3.0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL