[GODRIVER-549] Add ObjectID struct tag for strings Created: 10/Sep/18  Updated: 06/Feb/23

Status: Backlog
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to GODRIVER-533 ObjectId is not read to string by Dec... Closed
is related to GODRIVER-1354 Create ObjectIDCodec that accepts bso... Closed

 Description   

Add and implement a new struct tag that allows strings to be used as ObjectIDs. This will require adding support to the ObjectIDCodec and the StringCodec to recognize the struct tag and handle the values accordingly.



 Comments   
Comment by Danny Paul [ 15/Sep/19 ]

Really painful not having this feature.

Usually we end up having duplicate structs, with just the ObjectID field being different.

Would really love to have this feature. 

Thanks

Danny

Comment by Kristofer Brandow (Inactive) [ 04/Oct/18 ]

The work in GODRIVER-514 will provide functions to convert any type that can be converted to BSON to be converted to Extended JSON.

Comment by Emmanuel Leroy [ 04/Oct/18 ]

Thanks Kris,

 

That helps...

Still a bit of a pain to have to convert documents to another to output to json. A flag on the ToExtJSON method to define how to parse ObjectID would be welcome.

 

Comment by Kristofer Brandow (Inactive) [ 03/Oct/18 ]

Hi eleroy,

GODRIVER-533 requests that during decoding a string be a valid destination for an ObjectID. This ticket covers that functionality while additionally adding functionality to ensure that when that struct field is encoded into BSON it does so as an ObjectID instead of as a BSON string.

There are currently functions and methods in the objectid package that allow an objectid.ObjectID to be turned into a string representation. These are the Hex method and the FromHex function.

Thanks,

Kris

Comment by Emmanuel Leroy [ 03/Oct/18 ]

This says to supersedes 533 but I think it is a bit of a different problem.

It is quite a pain that the ObjectId parses as an array of integers instead of a string.

Is there a workaround in the mean time?

Generated at Thu Feb 08 08:34:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.