MCPcopy Index your code
hub / github.com/crowdsecurity/crowdsec / MapCreateBulk

Method MapCreateBulk

pkg/database/ent/client.go:1384–1395  ·  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(*LockCreate, int))

Source from the content-addressed store, hash-verified

1382// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
1383// a builder and applies setFunc on it.
1384func (c *LockClient) MapCreateBulk(slice any, setFunc func(*LockCreate, int)) *LockCreateBulk {
1385 rv := reflect.ValueOf(slice)
1386 if rv.Kind() != reflect.Slice {
1387 return &LockCreateBulk{err: fmt.Errorf("calling to LockClient.MapCreateBulk with wrong type %T, need slice", slice)}
1388 }
1389 builders := make([]*LockCreate, rv.Len())
1390 for i := 0; i < rv.Len(); i++ {
1391 builders[i] = c.Create()
1392 setFunc(builders[i], i)
1393 }
1394 return &LockCreateBulk{config: c.config, builders: builders}
1395}
1396
1397// Update returns an update builder for Lock.
1398func (c *LockClient) Update() *LockUpdate {

Callers

nothing calls this directly

Calls 3

CreateMethod · 0.95
KindMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected