修复 MongoDB 更新操作中 $set 字段为空时的 panic 问题

This commit is contained in:
2026-01-23 16:36:28 +08:00
committed by 张斌
parent a0598451e6
commit 9c8d40d3ba

View File

@@ -498,7 +498,10 @@ func (m *MongoDB) Update(ctx context.Context, filter bson.M, update bson.M, coll
}
}
}
setDoc := update["$set"].(bson.M)
setDoc := bson.M{}
if !g.IsEmpty(update["$set"]) {
setDoc = update["$set"].(bson.M)
}
if !g.IsEmpty(user.UserName) {
setDoc["updater"] = user.UserName
}