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

Method GetDatabaseCollection

db/database.go:2212–2228  ·  view source on GitHub ↗

GetDatabaseCollection returns a collection if one exists, otherwise error.

(scopeName, collectionName string)

Source from the content-addressed store, hash-verified

2210
2211// GetDatabaseCollection returns a collection if one exists, otherwise error.
2212func (dbc *DatabaseContext) GetDatabaseCollection(scopeName, collectionName string) (*DatabaseCollection, error) {
2213 if base.IsDefaultCollection(scopeName, collectionName) {
2214 return dbc.GetDefaultDatabaseCollection()
2215 }
2216 if dbc.Scopes == nil {
2217 return nil, fmt.Errorf("scope %q does not exist on this database", base.UD(scopeName))
2218 }
2219 collections, exists := dbc.Scopes[scopeName]
2220 if !exists {
2221 return nil, fmt.Errorf("scope %q does not exist on this database", base.UD(scopeName))
2222 }
2223 collection, exists := collections.Collections[collectionName]
2224 if !exists {
2225 return nil, fmt.Errorf("collection \"%s.%s\" does not exist on this database", base.UD(scopeName), base.UD(collectionName))
2226 }
2227 return collection, nil
2228}
2229
2230func (dbc *DatabaseContext) GetDefaultDatabaseCollection() (*DatabaseCollection, error) {
2231 col, exists := dbc.CollectionByID[base.DefaultCollectionID]

Callers 8

marshalPrincipalFunction · 0.80
TestCollectionStatsFunction · 0.80
_initCollectionsMethod · 0.80
getCollectionIdsAndNamesFunction · 0.80

Calls 4

IsDefaultCollectionFunction · 0.92
UDFunction · 0.92
ErrorfMethod · 0.80

Tested by 1

TestCollectionStatsFunction · 0.64