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

Method getDBConfig

rest/handler_config_database.go:18–36  ·  view source on GitHub ↗

Returns the current database config object for this request

()

Source from the content-addressed store, hash-verified

16
17// Returns the current database config object for this request
18func (h *handler) getDBConfig() (config *DbConfig, etagVersion string, err error) {
19 h.assertAdminOnly()
20 if h.server.BootstrapContext.Connection == nil {
21 if dbConfig := h.server.GetDatabaseConfig(h.db.Name); dbConfig != nil {
22 etagVersion = dbConfig.Version
23 if etagVersion == "" {
24 etagVersion = "0-"
25 }
26 return &dbConfig.DbConfig, etagVersion, nil
27 }
28 return nil, "", nil
29 } else if found, databaseConfig, err := h.server.fetchDatabase(h.ctx(), h.db.Name); err != nil {
30 return nil, "", err
31 } else if !found {
32 return nil, "", base.HTTPErrorf(http.StatusNotFound, "database config not found")
33 } else {
34 return &databaseConfig.DbConfig, databaseConfig.Version, nil
35 }
36}
37
38// Updates the database config via a callback function that can modify a `DbConfig`
39func (h *handler) mutateDbConfig(mutator func(*DbConfig) error) error {

Callers 2

Calls 5

assertAdminOnlyMethod · 0.95
ctxMethod · 0.95
HTTPErrorfFunction · 0.92
GetDatabaseConfigMethod · 0.80
fetchDatabaseMethod · 0.80

Tested by

no test coverage detected