MCPcopy
hub / github.com/wavetermdev/waveterm / DBUpdateFnErr

Function DBUpdateFnErr

pkg/wstore/wstore_dbops.go:331–343  ·  view source on GitHub ↗
(ctx context.Context, id string, updateFn func(T) error)

Source from the content-addressed store, hash-verified

329}
330
331func DBUpdateFnErr[T waveobj.WaveObj](ctx context.Context, id string, updateFn func(T) error) error {
332 return WithTx(ctx, func(tx *TxWrap) error {
333 val, err := DBMustGet[T](tx.Context(), id)
334 if err != nil {
335 return err
336 }
337 err = updateFn(val)
338 if err != nil {
339 return err
340 }
341 return DBUpdate(tx.Context(), val)
342 })
343}
344
345func DBInsert(ctx context.Context, val waveobj.WaveObj) error {
346 oid := waveobj.GetOID(val)

Callers 1

AttachJobToBlockFunction · 0.92

Calls 3

DBUpdateFunction · 0.85
WithTxFunction · 0.70
ContextMethod · 0.45

Tested by

no test coverage detected