How to make a decodable costum object id

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 1.0.0
    • Component/s: BSON
    • None
    • Environment:
      go1.12 linux/amd64
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Is there a way to make ObjectIDs with own methods that can be decoded from a BSON?
      I made me a simple custom ObjectID with a valid function:

      package primitive
      
      import (
      	primitive "go.mongodb.org/mongo-driver/bson/primitive"
      )
      
      type ObjectID struct {
      	primitive.ObjectID
      }
      
      func (o ObjectID) Validate() error {
      	return nil
      }
      

      But when I use that type instead of the original in a struct and try to decode a BSON I get the following error message:

      cannot decode objectID into a primitive.ObjectID
      

            Assignee:
            Unassigned
            Reporter:
            Karl Wolffgang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: