From a8a7318f68240ec4e4d3a2f2c918937ef0eb4cfc Mon Sep 17 00:00:00 2001 From: what Date: Sat, 6 May 2023 15:34:47 +0800 Subject: [PATCH] [feat] add base.GetDataIndexPrefixForRelations --- base/res_relation.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/base/res_relation.go b/base/res_relation.go index 61a158d..df31f4f 100644 --- a/base/res_relation.go +++ b/base/res_relation.go @@ -72,3 +72,13 @@ func GetModelJoinsForRelations(model string, items []ResRelation) (result []stri } return result } + +func GetDataIndexPrefixForRelations(model string, items []ResRelation) (result []any) { + result = append([]any{model}, result...) + for _, item := range items { + if item.Code == model && (item.Type == "hasMany" || item.Type == "hasOne") { + return append(GetDataIndexPrefixForRelations(item.RelationResource, items), result...) + } + } + return result +}