MCPcopy
hub / github.com/go-gorm/gorm / Update

Method Update

generics.go:705–721  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

703}
704
705func (s setCreateOrUpdateG[T]) Update(ctx context.Context) (rowsAffected int, err error) {
706 // Execute association operations
707 for _, assocOp := range s.assocOps {
708 if err := s.executeAssociationOperation(ctx, assocOp); err != nil {
709 return 0, err
710 }
711 }
712
713 // Execute assignment operations
714 if len(s.assigns) > 0 {
715 var r T
716 res := s.c.g.apply(ctx).Model(r).Clauses(clause.Set(s.assigns)).Updates(map[string]interface{}{})
717 return int(res.RowsAffected), res.Error
718 }
719
720 return 0, nil
721}
722
723func (s setCreateOrUpdateG[T]) Create(ctx context.Context) error {
724 // Execute association operations

Callers

nothing calls this directly

Calls 6

SetTypeAlias · 0.92
ClausesMethod · 0.80
ModelMethod · 0.80
applyMethod · 0.80
UpdatesMethod · 0.65

Tested by

no test coverage detected