Merge pull request #3340 from openimsdk/cherry-pick-91db181

fix: data version SetVersion will add record [Created by @icey-yu from #3304]
This commit is contained in:
chao 2025-05-14 16:37:44 +08:00 committed by GitHub
commit 8f615869e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -337,7 +337,7 @@ func SetVersion(coll *mongo.Collection, key string, version int) error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
option := options.Update().SetUpsert(true)
filter := bson.M{"key": key, "value": strconv.Itoa(version)}
filter := bson.M{"key": key}
update := bson.M{"$set": bson.M{"key": key, "value": strconv.Itoa(version)}}
return mongoutil.UpdateOne(ctx, coll, filter, update, false, option)
}