Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
1.0.3
-
None
-
None
-
Linux-ubuntu
Description
I have this following structure in my collection
{
|
"userID": "1234", |
"name": "Prakash", |
"email": "prakash@example.com", |
"street1": "some street 1", |
"street2" : "some street 2", |
"city" : "some city", |
"state": "some state", |
"country": "some country" |
}
|
I am using the following struct (Address struct embedded)
type User struct {
|
UserID string `bson:"userID"` |
Name string `bson:"name"` |
Email string `bson:email"`
|
Address
|
}
|
|
|
type Address struct {
|
Street1 string `bson:"street1"` |
Street2 string `bson:"street2"` |
City string `bson:"city"` |
State string `bson:"state"` |
Country string `bson:"country"` |
}
|
So, When I do
user := &User{}
|
collection.FindOne(ctx, bson.M{"userID": "1234"}).Decode(user) |
I am getting the userID, Name and Email field but the address fields are blank.
And when I am using this user struct, everything is working fine and
I am getting all data from MongoDB as required.
type User struct {
|
UserID string `bson:"userID"` |
Name string `bson:"name"` |
Email string `bson:email"`
|
Street1 string `bson:"street1"` |
Street2 string `bson:"street2"` |
City string `bson:"city"` |
State string `bson:"state"` |
Country string `bson:"country"` |
}
|