globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 231 forks source link

Add support for aliased ObjectIds #355

Closed dambrisco closed 1 year ago

dambrisco commented 5 years ago

Resolves #98 by way of the discussed "objectid" tag.

Specifically, this PR adds support for aliasing []byte and string fields to and from ObjectIds. Other types are not supportable at this time, at least without fairly contrived scenarios like 3-length arrays of Int32, but adding support for other types in the future should be fairly easy if needed.

dambrisco commented 5 years ago

Looks like I accidentally stomped on some code in a rebase, I'll get that fixed.

Fixed.

ilius commented 5 years ago

I just saw this after I posted my PR :( https://github.com/globalsign/mgo/pull/357

ilius commented 5 years ago

Yours is more flexible, but looks like it does not support string pointer, which is much more useful than array...

dambrisco commented 5 years ago

@ilius It should be fairly straightforward to add string pointer support to my code. I can look into doing that within the next week.

ilius commented 5 years ago

Oh crud! My PR is based on master, and looks like the upstream master is not merged into development for a while and there are conflicts!

I think we better pass info *fieldInfo argument (to addElem or readElemTo) instead of boolean, so that we don't have to keep adding arguments for each flag.

ilius commented 5 years ago

Please take a look if you may: https://github.com/globalsign/mgo/pull/357 I'm closing my PR.