decimal icon indicating copy to clipboard operation
decimal copied to clipboard

[FEAT]: add support to official mongo providers and legacy mgo?

Open quenbyako opened this issue 3 years ago • 2 comments

So, our team still working with legacy provider to mongo gopkg.in/mgo.v2 and currently, we're migrating to official mongo driver. Both of them has different bson serialization library, and, what is worse, there is no one bson lib in both packages which is allowing custom callbacks to parse specific types like in mapstructure, to provide additional marshaling methods without explicitly extend predefined types.

So, my idea: could we please implement, at least, new mongo interfaces? (UnmarshalBSON and MarshalBSON) Honestly, it would be really amazing, if we could add even legacy interfaces, but it's not so necessary. Note that this feature doesn't even required to add new dependency, bson float128 looks pretty simple to hardcode marshaling, so no needs to add unnecessary dep.

Actually i asking to understand how well contributions accepted, cause i have this patch already and just interested in the desire of maintainers to add this functionality to the package. If yes, i'll create PR

quenbyako avatar Jun 27 '21 19:06 quenbyako

Hi @quenbyako. The only reason why we have not accepted any previous community implementations was the fact they included external dependencies, and we want to keep this library dependency-free. Also, personally, I had no time latelty to sit and try to resolve this issue by myself. If you already have a dependency-free implementation that would add those missing interfaces, I would be more than glad to add this functionality to this library.

mwoss avatar Jul 01 '21 07:07 mwoss

This new functionality would really be great. Have issues currently with saving a struct with a Decimal field to a MongoDB database. @quenbyako, it would be awesome if you have a patch that works with the new MongoDB driver and would be willing to share it as a PR. Thanks a lot in advance 😃

marcushammar avatar Jul 28 '21 12:07 marcushammar