decimal icon indicating copy to clipboard operation
decimal copied to clipboard

UnmarshalBSON and MarshalBSON serialization

Open 1140251 opened this issue 4 years ago • 2 comments

when saving to mongodb with mongo go driver, the decimal.Big is created with an empty context only. Maybe you don't want this dependency, but how can serialize this?

As a workaround I'm saving as Float64 and converting to decimal.Big when performing operations, but is not the most eloquent way for me.

1140251 avatar Jun 22 '21 11:06 1140251

Could you elaborate a little bit more?

ericlagergren avatar Oct 22 '21 10:10 ericlagergren

I think he means that when saving a decimal.Big in mongodb this is the result that is written into the db. image I'm too wondering if it would make if this library would support marshaling into (I guess) a Decimal128 as supported by mongodb.

https://github.com/mongodb/mongo-go-driver/blob/master/bson/primitive/decimal.go

trading-peter avatar Nov 09 '21 00:11 trading-peter