How to operate struct with unfixed fields in go mongodb

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.

May.29,2022

just use the most complete one. If the old data is not available, it will be empty


take a look at the Get Started guide, which describes the use of BSON object mapping documents: https://www.mongodb.com/blog/...

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bba832-3021b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bba832-3021b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?