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)
, bson.M{"$inc": bson.M{"sequence": 1}},
options.FindOneAndUpdate().SetUpsert(true)).Decode(&model)
if err != nil
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。