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

Method handleGetCollectionConfigSync

rest/admin_api.go:1064–1101  ·  view source on GitHub ↗

GET collection config sync function

()

Source from the content-addressed store, hash-verified

1062
1063// GET collection config sync function
1064func (h *handler) handleGetCollectionConfigSync() error {
1065 h.assertAdminOnly()
1066 var (
1067 etagVersion string
1068 syncFunction string
1069 )
1070
1071 if h.server.BootstrapContext.Connection != nil {
1072 found, dbConfig, err := h.server.fetchDatabase(h.ctx(), h.db.Name)
1073 if err != nil {
1074 return err
1075 }
1076
1077 if !found {
1078 return base.HTTPErrorf(http.StatusNotFound, "database config not found")
1079 }
1080
1081 etagVersion = dbConfig.Version
1082
1083 if dbConfig.Scopes != nil {
1084 scope, ok := dbConfig.Scopes[h.collection.ScopeName]
1085 if ok {
1086 collectionConfig, ok := scope.Collections[h.collection.Name]
1087 if ok && collectionConfig.SyncFn != nil {
1088 syncFunction = *collectionConfig.SyncFn
1089
1090 }
1091 }
1092 } else if dbConfig.Sync != nil {
1093 syncFunction = *dbConfig.Sync
1094 }
1095 }
1096
1097 h.setEtag(etagVersion)
1098 h.writeJavascript(syncFunction)
1099 base.Audit(h.ctx(), base.AuditIDReadDatabaseConfig, nil)
1100 return nil
1101}
1102
1103// DELETE a collection sync function
1104func (h *handler) handleDeleteCollectionConfigSync() error {

Callers

nothing calls this directly

Calls 7

assertAdminOnlyMethod · 0.95
ctxMethod · 0.95
setEtagMethod · 0.95
writeJavascriptMethod · 0.95
HTTPErrorfFunction · 0.92
AuditFunction · 0.92
fetchDatabaseMethod · 0.80

Tested by

no test coverage detected