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)
| 579 | // This function is useful for non-unique edges, such as O2M and M2M, where the same parent can |
| 580 | // have multiple children. |
| 581 | func 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. |
| 592 | func (l *NeighborsLimit) Modifier(partitionBy string, limit int, orderBy ...sql.Querier) func(s *sql.Selector) { |
searching dependent graphs…