Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

muktihari/decimalcodec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

decimal.Decimal{} codec

Go Doc Go Report Card

Encoder and Decoder Codec for decimal.Decimal{} as primitive.Decimal128 on official mongo-go-driver

Usage

import (
    ...
    "github.com/muktihari/decimalcodec"
)

func main() {
    rb := bsoncodec.NewRegistryBuilder()

    // you might want to include defaults encoder and decoder as well
    bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb)
    bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb)

    decimalcodec.RegisterEncodeDecoder(rb)
    
    registry := rb.Build()
    
    client, err := mongo.Connect(context.Background(),
        options.Client().
            ApplyURI("mongodb://localhost:27017").
            SetRegistry(registry),
    )
    ...
}

About

Encoder and Decoder Codec for shopspring's decimal.Decimal{} as primitive.Decimal128 on official mongo-go-driver

Topics

Resources

License

Stars

Watchers

Forks

Languages