modulepackage
0.1.1
Repository: https://github.com/vonix-networks/bsonuuid.git
Documentation: pkg.go.dev
# README
UUID Support for BSON Serialization in Mongo Go Driver
Motivation
While working with a legacy system we are indexing a fairly large amount of data into a time series collection where the IDs are UUID types. Our first instinct was to use strings as they are easier to work around with the go drivers for MongoDB, but we can cut our index sizes considerably using the binary representation. Thus, bson-uuid was born.
Installation
go get -u github.com/vonix-networks/bsonuuid
Deployment
There is a builder for a quick replacement if this is the only change to the registry needed:
client, err := mongo.Connect(context.Background(),
options.Client().ApplyURI("uri"),
options.Client().SetRegistry(bsonuuid.BuildRegistry()))
This will enable serialization from and to the standard UUID MongoDB type (specifically the binary subtype 0x04). It will also attempt to automatically parse strings.
Change History
- v0.1.0 - Initial release
- v0.1.1 - Fixed module cache issues
# Functions
No description provided by the author
UUIDDecodeValue attempts to unmarshal a string or a binary with subtype 0x00 (generic) or 0x04 (uuid) into an uuid.UUID type.
UUIDEncodeValue attempts to marshal an uuid.UUID type into a MongoDB binary uuid type.
# Variables
No description provided by the author