From 94e1b0355460d95dbe7a13a5f10d7f1ba0aa2a0f Mon Sep 17 00:00:00 2001 From: Patryk Kowalewski Date: Thu, 2 Nov 2023 10:14:54 +0100 Subject: [PATCH] Refactor bsondec encoder/decoder to match latest api --- mongo.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mongo.go b/mongo.go index 7e381c5..94579c2 100644 --- a/mongo.go +++ b/mongo.go @@ -7,11 +7,14 @@ import ( "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()) } -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() if err != nil { return err