(s *schema.Schema, tableName string, skipNil, recursive bool, data map[string]interface{})
| 1048 | } |
| 1049 | |
| 1050 | func (tx *Transaction) decode(s *schema.Schema, tableName string, skipNil, recursive bool, data map[string]interface{}) map[string]interface{} { |
| 1051 | resourceData := map[string]interface{}{} |
| 1052 | |
| 1053 | manager := schema.GetManager() |
| 1054 | db := tx.db |
| 1055 | for _, property := range s.Properties { |
| 1056 | handler := db.handler(&property) |
| 1057 | value := data[makeColumnID(tableName, property)] |
| 1058 | if value != nil || (property.Nullable && !skipNil) { |
| 1059 | decoded, err := handler.decode(&property, value) |
| 1060 | if err != nil { |
| 1061 | log.Error(fmt.Sprintf("SQL List decoding error: %s", err)) |
| 1062 | } |
| 1063 | resourceData[property.ID] = decoded |
| 1064 | } |
| 1065 | if property.RelationProperty != "" && recursive { |
| 1066 | relatedSchema, _ := manager.Schema(property.Relation) |
| 1067 | aliasTableName := makeAliasTableName(tableName, property) |
| 1068 | relatedResourceData := tx.decode(relatedSchema, aliasTableName, skipNil, recursive, data) |
| 1069 | if len(relatedResourceData) > 0 || !skipNil { |
| 1070 | resourceData[property.RelationProperty] = relatedResourceData |
| 1071 | } |
| 1072 | } |
| 1073 | } |
| 1074 | |
| 1075 | return resourceData |
| 1076 | } |
| 1077 | |
| 1078 | //CountContext count all matching resources in the db |
| 1079 | func (tx *Transaction) CountContext(ctx context.Context, s *schema.Schema, filter transaction.Filter) (res uint64, err error) { |
no test coverage detected