Details
-
Task
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
Mongodb: 4.0.5
Go-Driver: 1.0.3
Golang: 1.12
Description
Hi, i want to custom MarshalBSONValue like GODRIVER-980
type StructA struct {
|
ID `bson:"_id"` // <-- Embedded |
Foo string `bson: "Foo"` |
}
|
|
|
type ID string
|
|
|
func (e ID) MarshalBSONValue() (bsontype.Type, []byte, error) { |
return bsontype.String, bsoncore.AppendString(nil, string(e)), nil |
}
|
But my struct is embedded, it said
cannot transform type *main.StructA to a BSON Document: WriteValueBytes can only write while positioned on a Element or Value but is positioned on a TopLevel |
What should i do?