Refactor bsondec encoder/decoder to match latest api

This commit is contained in:
Patryk Kowalewski 2023-11-02 10:14:54 +01:00
parent 32f3e9574f
commit 94e1b03554

View file

@ -7,11 +7,14 @@ import (
"go.mongodb.org/mongo-driver/bson/bsonrw" "go.mongodb.org/mongo-driver/bson/bsonrw"
) )
func Encoder(encodeContext bsoncodec.EncodeContext, writer bsonrw.ValueWriter, value reflect.Value) error { type BsonDecoderEncoder struct {
}
func (BsonDecoderEncoder) EncodeValue(encodeContext bsoncodec.EncodeContext, writer bsonrw.ValueWriter, value reflect.Value) error {
return writer.WriteString(value.Interface().(Decimal).String()) return writer.WriteString(value.Interface().(Decimal).String())
} }
func Decoder(decodeContext bsoncodec.DecodeContext, reader bsonrw.ValueReader, value reflect.Value) error { func (BsonDecoderEncoder) DecodeValue(decodeContext bsoncodec.DecodeContext, reader bsonrw.ValueReader, value reflect.Value) error {
str, err := reader.ReadString() str, err := reader.ReadString()
if err != nil { if err != nil {
return err return err