Reputation: 11
I have built a program in Go with the next structure
type A struct {
feature []string
}
type B struct {
title string
other_feature []A
}
I tried to use the bson package but only the title appears on the database after execution. Does anyone have a solution?
Upvotes: 1
Views: 1521
Reputation: 120999
You need to export the field names by starting the field name with an uppercase letter. Use the bson field tag to specify the named used in the database.
type A struct {
Feature []string `bson:"feature"`
}
type B struct {
Title string `bson:"title"`
Other_feature []A `bson:"other_feature"`
}
Upvotes: 5