mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
21 lines
512 B
Go
21 lines
512 B
Go
package db
|
|
|
|
import (
|
|
"context"
|
|
|
|
"yunion.io/x/sqlchemy"
|
|
|
|
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
|
)
|
|
|
|
func Update(model IModel, updateFunc func() error) (map[string]sqlchemy.SUpdateDiff, error) {
|
|
return model.GetModelManager().TableSpec().Update(model, updateFunc)
|
|
}
|
|
|
|
func UpdateWithLock(ctx context.Context, model IModel, updateFunc func() error) (map[string]sqlchemy.SUpdateDiff, error) {
|
|
lockman.LockObject(ctx, model)
|
|
defer lockman.ReleaseObject(ctx, model)
|
|
|
|
return Update(model, updateFunc)
|
|
}
|