mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-06 14:26:22 +00:00
Recursive crud fix
This commit is contained in:
parent
53a4e67f70
commit
35f23b6d9e
@ -406,13 +406,23 @@ func ShouldUseNestedProcessor(data map[string]interface{}, model interface{}, re
|
||||
relInfo := relationshipHelper.GetRelationshipInfo(modelType, key)
|
||||
if relInfo != nil {
|
||||
// Check if the value is actually nested data (object or array)
|
||||
switch value.(type) {
|
||||
case map[string]interface{}, []interface{}, []map[string]interface{}:
|
||||
logger.Debug("Found nested relation field: %s", key)
|
||||
switch v := value.(type) {
|
||||
case map[string]interface{}:
|
||||
//logger.Debug("Found nested relation field: %s", key)
|
||||
return ShouldUseNestedProcessor(v, relInfo.RelatedModel, relationshipHelper)
|
||||
case []interface{}, []map[string]interface{}:
|
||||
//logger.Debug("Found nested relation field: %s", key)
|
||||
for _, item := range v.([]interface{}) {
|
||||
if itemMap, ok := item.(map[string]interface{}); ok {
|
||||
if ShouldUseNestedProcessor(itemMap, relInfo.RelatedModel, relationshipHelper) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user