-
Type:
Task
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 1.0.0
-
Component/s: BSON
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have an interface, let's say:
type ITest interface {
Hello()
}
Struct, which implements this:
type STest struct {
Greeting string
}
func (s *STest) Hello() {
fmt.Println(s.Greeting)
}
And an array of ITest interfaces with a STest struct as first element:
var iArr []ITest
iArr = append(iArr, &STest{"heelloo"})
When i'm trying to create an update document for UpdateOne method, i do the following:
bson.D{{"$set", bson.D{{"somefield", iArr}}}}
and getting an error:
cannot transform type primitive.D to a BSON Document: no encoder found for models.ITest
But for the separate element it works like a charm (no error, present in db):
bson.D{{"$set", bson.D{{"somefield", iArr[0]}}}}
So is it bug or something?
PS: i'm using v1.0.0-rc1+prerelease version