bson

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry *bson.Registry

Registry is a custom BSON registry that handles UUID types as strings. In mongo-driver v2, there is no global default registry. Consumers must pass this registry to their MongoDB client, database, or collection via options.Client().SetRegistry(bsoncodec.Registry).

Functions

func Marshal added in v0.17.0

func Marshal(val any) ([]byte, error)

Marshal marshals a value to BSON using the custom Registry that handles UUID encoding as strings. Use this instead of bson.Marshal to ensure consistent UUID encoding across driver versions.

func Unmarshal added in v0.17.0

func Unmarshal(data []byte, val any) error

Unmarshal unmarshals BSON data using the custom Registry that handles UUID decoding from both strings and binary formats. Use this instead of bson.Unmarshal to ensure backward-compatible UUID decoding.

Types

type CommandCodec added in v0.15.0

type CommandCodec struct{}

CommandCodec is a codec for marshaling and unmarshaling commands to and from bytes in BSON format.

func (CommandCodec) MarshalCommand added in v0.15.0

func (CommandCodec) MarshalCommand(ctx context.Context, cmd eh.Command) ([]byte, error)

MarshalCommand marshals a command into bytes in BSON format.

func (CommandCodec) UnmarshalCommand added in v0.15.0

func (CommandCodec) UnmarshalCommand(ctx context.Context, b []byte) (eh.Command, context.Context, error)

UnmarshalCommand unmarshals a command from bytes in BSON format.

type EventCodec

type EventCodec struct{}

EventCodec is a codec for marshaling and unmarshaling events to and from bytes in BSON format.

func (*EventCodec) MarshalEvent

func (c *EventCodec) MarshalEvent(ctx context.Context, event eh.Event) ([]byte, error)

MarshalEvent marshals an event into bytes in BSON format.

func (*EventCodec) UnmarshalEvent

func (c *EventCodec) UnmarshalEvent(ctx context.Context, b []byte) (eh.Event, context.Context, error)

UnmarshalEvent unmarshals an event from bytes in BSON format.

Jump to

Keyboard shortcuts

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