Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-565

Decode date field to int64 get zero value

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 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}
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            chi914 Mark Leung
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: