MCPcopy
hub / github.com/ent/ent / LimitNeighbors

Function LimitNeighbors

dialect/sql/sqlgraph/graph.go:581–589  ·  view source on GitHub ↗

LimitNeighbors returns a modifier that limits the number of neighbors (rows) loaded per parent row (node). The "partitionBy" is the foreign-key column (edge) to partition the window function by, the "limit" is the maximum number of rows per parent, and the "orderBy" defines the order of how neighbor

(partitionBy string, limit int, orderBy ...sql.Querier)

Source from the content-addressed store, hash-verified

579// This function is useful for non-unique edges, such as O2M and M2M, where the same parent can
580// have multiple children.
581func LimitNeighbors(partitionBy string, limit int, orderBy ...sql.Querier) func(*sql.Selector) {
582 l := &NeighborsLimit{
583 SrcCTE: "src_query",
584 LimitCTE: "limited_query",
585 RowNumber: "row_number",
586 DefaultOrderField: "id",
587 }
588 return l.Modifier(partitionBy, limit, orderBy...)
589}
590
591// Modifier returns a modifier function that limits the number of rows of the eager load query.
592func (l *NeighborsLimit) Modifier(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) {

Callers 1

TestLimitNeighborsFunction · 0.85

Calls 1

ModifierMethod · 0.95

Tested by 1

TestLimitNeighborsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…