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

Method MapCreateBulk

ent/client.go:2507–2518  ·  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(*StoragePolicyCreate, int))

Source from the content-addressed store, hash-verified

2505// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
2506// a builder and applies setFunc on it.
2507func (c *StoragePolicyClient) MapCreateBulk(slice any, setFunc func(*StoragePolicyCreate, int)) *StoragePolicyCreateBulk {
2508 rv := reflect.ValueOf(slice)
2509 if rv.Kind() != reflect.Slice {
2510 return &StoragePolicyCreateBulk{err: fmt.Errorf("calling to StoragePolicyClient.MapCreateBulk with wrong type %T, need slice", slice)}
2511 }
2512 builders := make([]*StoragePolicyCreate, rv.Len())
2513 for i := 0; i < rv.Len(); i++ {
2514 builders[i] = c.Create()
2515 setFunc(builders[i], i)
2516 }
2517 return &StoragePolicyCreateBulk{config: c.config, builders: builders}
2518}
2519
2520// Update returns an update builder for StoragePolicy.
2521func (c *StoragePolicyClient) Update() *StoragePolicyUpdate {

Callers

nothing calls this directly

Calls 2

CreateMethod · 0.95
LenMethod · 0.45

Tested by

no test coverage detected