MCPcopy Create free account
hub / github.com/crowdsecurity/crowdsec / sqlAll

Method sqlAll

pkg/database/ent/allowlist_query.go:370–404  ·  view source on GitHub ↗
(ctx context.Context, hooks ...queryHook)

Source from the content-addressed store, hash-verified

368}
369
370func (_q *AllowListQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AllowList, error) {
371 var (
372 nodes = []*AllowList{}
373 _spec = _q.querySpec()
374 loadedTypes = [1]bool{
375 _q.withAllowlistItems != nil,
376 }
377 )
378 _spec.ScanValues = func(columns []string) ([]any, error) {
379 return (*AllowList).scanValues(nil, columns)
380 }
381 _spec.Assign = func(columns []string, values []any) error {
382 node := &AllowList{config: _q.config}
383 nodes = append(nodes, node)
384 node.Edges.loadedTypes = loadedTypes
385 return node.assignValues(columns, values)
386 }
387 for i := range hooks {
388 hooks[i](ctx, _spec)
389 }
390 if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
391 return nil, err
392 }
393 if len(nodes) == 0 {
394 return nodes, nil
395 }
396 if query := _q.withAllowlistItems; query != nil {
397 if err := _q.loadAllowlistItems(ctx, query, nodes,
398 func(n *AllowList) { n.Edges.AllowlistItems = []*AllowListItem{} },
399 func(n *AllowList, e *AllowListItem) { n.Edges.AllowlistItems = append(n.Edges.AllowlistItems, e) }); err != nil {
400 return nil, err
401 }
402 }
403 return nodes, nil
404}
405
406func (_q *AllowListQuery) loadAllowlistItems(ctx context.Context, query *AllowListItemQuery, nodes []*AllowList, init func(*AllowList), assign func(*AllowList, *AllowListItem)) error {
407 edgeIDs := make([]driver.Value, len(nodes))

Callers 1

loadAllowlistItemsMethod · 0.45

Calls 4

querySpecMethod · 0.95
assignValuesMethod · 0.95
loadAllowlistItemsMethod · 0.95
scanValuesMethod · 0.45

Tested by

no test coverage detected