ExpandRecords expands the relations of the provided Record models list. If optFetchFunc is not set, then a default function will be used that returns all relation records. Returns a map with the failed expand parameters and their errors.
(records []*Record, expands []string, optFetchFunc ExpandFetchFunc)
| 32 | // |
| 33 | // Returns a map with the failed expand parameters and their errors. |
| 34 | func (app *BaseApp) ExpandRecords(records []*Record, expands []string, optFetchFunc ExpandFetchFunc) map[string]error { |
| 35 | normalized := normalizeExpands(expands) |
| 36 | |
| 37 | failed := map[string]error{} |
| 38 | |
| 39 | for _, expand := range normalized { |
| 40 | if err := app.expandRecords(records, expand, optFetchFunc, 1); err != nil { |
| 41 | failed[expand] = err |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return failed |
| 46 | } |
| 47 | |
| 48 | // Deprecated |
| 49 | var indirectExpandRegexOld = regexp.MustCompile(`^(\w+)\((\w+)\)$`) |
no test coverage detected