MCPcopy Create free account
hub / github.com/Comfy-Org/registry-backend / sqlSave

Method sqlSave

ent/storagefile_create.go:204–225  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

202}
203
204func (sfc *StorageFileCreate) sqlSave(ctx context.Context) (*StorageFile, error) {
205 if err := sfc.check(); err != nil {
206 return nil, err
207 }
208 _node, _spec := sfc.createSpec()
209 if err := sqlgraph.CreateNode(ctx, sfc.driver, _spec); err != nil {
210 if sqlgraph.IsConstraintError(err) {
211 err = &ConstraintError{msg: err.Error(), wrap: err}
212 }
213 return nil, err
214 }
215 if _spec.ID.Value != nil {
216 if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
217 _node.ID = *id
218 } else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
219 return nil, err
220 }
221 }
222 sfc.mutation.id = &_node.ID
223 sfc.mutation.done = true
224 return _node, nil
225}
226
227func (sfc *StorageFileCreate) createSpec() (*StorageFile, *sqlgraph.CreateSpec) {
228 var (

Callers

nothing calls this directly

Calls 5

checkMethod · 0.95
createSpecMethod · 0.95
CreateNodeMethod · 0.65
ErrorMethod · 0.65
ScanMethod · 0.45

Tested by

no test coverage detected