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

Method MapCreateBulk

ent/client.go:2706–2717  ·  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(*TaskCreate, int))

Source from the content-addressed store, hash-verified

2704// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
2705// a builder and applies setFunc on it.
2706func (c *TaskClient) MapCreateBulk(slice any, setFunc func(*TaskCreate, int)) *TaskCreateBulk {
2707 rv := reflect.ValueOf(slice)
2708 if rv.Kind() != reflect.Slice {
2709 return &TaskCreateBulk{err: fmt.Errorf("calling to TaskClient.MapCreateBulk with wrong type %T, need slice", slice)}
2710 }
2711 builders := make([]*TaskCreate, rv.Len())
2712 for i := 0; i < rv.Len(); i++ {
2713 builders[i] = c.Create()
2714 setFunc(builders[i], i)
2715 }
2716 return &TaskCreateBulk{config: c.config, builders: builders}
2717}
2718
2719// Update returns an update builder for Task.
2720func (c *TaskClient) Update() *TaskUpdate {

Callers

nothing calls this directly

Calls 2

CreateMethod · 0.95
LenMethod · 0.45

Tested by

no test coverage detected