getScopeCollTypeMappings will return a deduplicated list of collection names when skipMappings is enabled.
(im *mapping.IndexMappingImpl, skipMappings bool)
| 172 | // getScopeCollTypeMappings will return a deduplicated |
| 173 | // list of collection names when skipMappings is enabled. |
| 174 | func getScopeCollTypeMappings(im *mapping.IndexMappingImpl, |
| 175 | skipMappings bool) (scope string, |
| 176 | cols []string, typeMappings []string, err error) { |
| 177 | // index the _default/_default scope and collection when |
| 178 | // default mapping is enabled. |
| 179 | if im.DefaultMapping.Enabled { |
| 180 | scope = defaultScopeName |
| 181 | cols = []string{defaultCollName} |
| 182 | typeMappings = []string{""} |
| 183 | } |
| 184 | |
| 185 | hash := make(map[string]struct{}, len(im.TypeMapping)) |
| 186 | for tp, dm := range im.TypeMapping { |
| 187 | if !dm.Enabled { |
| 188 | continue |
| 189 | } |
| 190 | s, c, t := scopeCollTypeMapping(tp) |
| 191 | key := c |
| 192 | if !skipMappings { |
| 193 | key += t |
| 194 | } |
| 195 | if _, exists := hash[key]; !exists { |
| 196 | hash[key] = struct{}{} |
| 197 | cols = append(cols, c) |
| 198 | if !skipMappings { |
| 199 | typeMappings = append(typeMappings, t) |
| 200 | } |
| 201 | } |
| 202 | if scope == "" { |
| 203 | scope = s |
| 204 | continue |
| 205 | } |
| 206 | if scope != s { |
| 207 | return "", nil, nil, fmt.Errorf("collection_utils: multiple scopes"+ |
| 208 | " found: '%s', '%s'; index can only span collections on a single"+ |
| 209 | " scope", scope, s) |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | return scope, cols, typeMappings, nil |
| 214 | } |
| 215 | |
| 216 | // validateScopeCollFromMappings performs the $scope.$collection |
| 217 | // validations in the type mappings defined. It also performs |