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

Method MapCreateBulk

ent/client.go:1585–1596  ·  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(*NodeCreate, int))

Source from the content-addressed store, hash-verified

1583// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1584// a builder and applies setFunc on it.
1585func (c *NodeClient) MapCreateBulk(slice any, setFunc func(*NodeCreate, int)) *NodeCreateBulk {
1586 rv := reflect.ValueOf(slice)
1587 if rv.Kind() != reflect.Slice {
1588 return &NodeCreateBulk{err: fmt.Errorf("calling to NodeClient.MapCreateBulk with wrong type %T, need slice", slice)}
1589 }
1590 builders := make([]*NodeCreate, rv.Len())
1591 for i := 0; i < rv.Len(); i++ {
1592 builders[i] = c.Create()
1593 setFunc(builders[i], i)
1594 }
1595 return &NodeCreateBulk{config: c.config, builders: builders}
1596}
1597
1598// Update returns an update builder for Node.
1599func (c *NodeClient) Update() *NodeUpdate {

Callers

nothing calls this directly

Calls 2

CreateMethod · 0.95
LenMethod · 0.45

Tested by

no test coverage detected