mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-23 04:40:49 +01:00
Refactor bsondec encoder/decoder to match latest api
This commit is contained in:
parent
32f3e9574f
commit
94e1b03554
1 changed files with 5 additions and 2 deletions
7
mongo.go
7
mongo.go
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue