When having a struct like this:
type TestStruct struct {
ID objectid.ObjectID `bson:"_id"`
Desc string `bson:"desc"`
}
func Create() {
t := TestStruct{
Desc: "Testing 1234"
}
.....InsertOne(context.Background(), t, nil)
}
This creates a byte[12] (Binary) value in the database instead of an objectID. When removing the `bson: "_id"` tag. It automatically creates a correct objectID. But then there is no bson mapping to the ID field in the struct.
- is caused by
-
GODRIVER-324 Handle objectid.ObjectID in the bson.Encoder
-
- Closed
-