MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / MapCreateBulk

Method MapCreateBulk

ent/client.go:671–682  ·  view source on GitHub ↗

MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates a builder and applies setFunc on it.

(slice any, setFunc func(*EntityCreate, int))

Source from the content-addressed store, hash-verified

669// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
670// a builder and applies setFunc on it.
671func (c *EntityClient) MapCreateBulk(slice any, setFunc func(*EntityCreate, int)) *EntityCreateBulk {
672 rv := reflect.ValueOf(slice)
673 if rv.Kind() != reflect.Slice {
674 return &EntityCreateBulk{err: fmt.Errorf("calling to EntityClient.MapCreateBulk with wrong type %T, need slice", slice)}
675 }
676 builders := make([]*EntityCreate, rv.Len())
677 for i := 0; i < rv.Len(); i++ {
678 builders[i] = c.Create()
679 setFunc(builders[i], i)
680 }
681 return &EntityCreateBulk{config: c.config, builders: builders}
682}
683
684// Update returns an update builder for Entity.
685func (c *EntityClient) Update() *EntityUpdate {

Callers

nothing calls this directly

Calls 2

CreateMethod · 0.95
LenMethod · 0.45

Tested by

no test coverage detected