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

Continue run FindOneAndUpdate to get sequence ,but not inc, still the first result

    • Type: Icon: Bug Bug
    • Resolution: Gone away
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: 1.8.2
    • Component/s: BSON
    • Labels:

      type Sequence struct

      {     Id       primitive.ObjectID `json:"id"   form:"id"  bson:"_id"`     Field    string             `json:"field" form:"field" bson:"field"`     Sequence int64              `json:"sequence" form:"sequence" bson:"sequence"` }

       
      func (model *Sequence) GetNextSequence(field string) (int64, error)

      {     err := util.C(model).FindOneAndUpdate(context.TODO(),         bson.M\{"field": "Account.Number"}

      , bson.M{"$inc": bson.M{"sequence": 1}},
              options.FindOneAndUpdate().SetUpsert(true)).Decode(&model)
          if err != nil

      {         return -1, err     }

          return model.Sequence, nil
      }
      The first run func,can get correct result.Continue to run func  ,but not inc, still the first result. What is the right thing to do?
      Thanks。

            Assignee:
            benji.rewis@mongodb.com Benji Rewis (Inactive)
            Reporter:
            8080268@qq.com oy h
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: