-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 0.0.13
-
Component/s: BSON
-
None
DocumentResult shows correctly when passing to a bson.NewDocument.
bson.Document\{bson.Element{[objectID]"_id": ObjectID("5b989bbe733326cf1622e06a")}, bson.Element\{[UTC datetime]"datetime": 1536727804734}}
But get zero-value after marshaling struct.
type syncDateTime struct { ID objectid.ObjectID `json:"id" bson:"_id, omitempty"` LastUpdateTime int64 `json:"datetime" bson:"datetime"` } filter := bson.NewDocument(bson.EC.String("type_key", "lastUpdateTime")) projection := findopt.Projection(bson.NewDocument(bson.EC.Int32("datetime", 1))) sort := findopt.Sort(bson.NewDocument(bson.EC.Int32("datetime", -1))) result := syncDateTime{} err := cConfig.FindOne(context.Background(), filter, projection, sort).Decode(&result) {ObjectID("5b989bbe733326cf1622e06a") 0}
- depends on
-
GODRIVER-577 Add struct tags to choose BSON types
- Closed