when I first came into contact with GO, I encountered some problems.
if it is mysql, our fields are fixed, but in mongodb, each record can have different fields. For example, the first record field is
{A B C D}
. The second record is
{A B C D E}
E and there is also an object field E {name sex address}
these fields can exist in mongdb because it is stored in bjson, so here"s the problem. When I created model, the struct I defined was fixed, such as
type user struct {
A string
B string
C string
D string
}
but this does not satisfy the second case at all, because there may be more fields in the third case, because the business needs, just like creating a struct dynamically, how can we solve such a problem? Thank you for your advice.