MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / buildCollectionIndexData

Function buildCollectionIndexData

rest/database_init_manager.go:186–208  ·  view source on GitHub ↗

buildCollectionIndexData determines the set of indexes required for each collection in the config, including the metadata collection

(config *DatabaseConfig)

Source from the content-addressed store, hash-verified

184// buildCollectionIndexData determines the set of indexes required for each collection in the config, including
185// the metadata collection
186func buildCollectionIndexData(config *DatabaseConfig) CollectionInitData {
187 if len(config.Scopes) == 0 {
188 return CollectionInitData{base.DefaultScopeAndCollectionName(): db.IndexesAll}
189 }
190
191 defaultScopeAndCollectionMetadataIndexes := db.IndexesMetadataOnly
192
193 collectionInitData := make(CollectionInitData)
194 for scopeName, scopeConfig := range config.Scopes {
195 for collectionName := range scopeConfig.Collections {
196 scName := base.ScopeAndCollectionName{Scope: scopeName, Collection: collectionName}
197 if scName.IsDefault() {
198 defaultScopeAndCollectionMetadataIndexes = db.IndexesAll
199 continue
200 }
201 collectionInitData[scName] = db.IndexesWithoutMetadata
202 }
203 }
204
205 collectionInitData[base.DefaultScopeAndCollectionName()] = defaultScopeAndCollectionMetadataIndexes
206
207 return collectionInitData
208}
209
210// DatabaseInitWorker performs async database initialization tasks that should be performed in the background,
211// independent of the database being reloaded for config changes

Calls 1

Tested by 1