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

Method Create

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

Source from the content-addressed store, hash-verified

721}
722
723func (s setCreateOrUpdateG[T]) Create(ctx context.Context) error {
724 // Execute association operations
725 for _, assocOp := range s.assocOps {
726 if err := s.executeAssociationOperation(ctx, assocOp); err != nil {
727 return err
728 }
729 }
730
731 // Execute assignment operations
732 if len(s.assigns) > 0 {
733 data := make(map[string]interface{}, len(s.assigns))
734 for _, a := range s.assigns {
735 data[a.Column.Name] = a.Value
736 }
737 var r T
738 return s.c.g.apply(ctx).Model(r).Create(data).Error
739 }
740
741 return nil
742}
743
744// executeAssociationOperation executes an association operation
745func (s setCreateOrUpdateG[T]) executeAssociationOperation(ctx context.Context, op clause.Association) error {

Callers

nothing calls this directly

Calls 4

ModelMethod · 0.80
applyMethod · 0.80
CreateMethod · 0.65

Tested by

no test coverage detected