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

Function GetStringArrayProperty

db/revision.go:527–544  ·  view source on GitHub ↗
(body map[string]interface{}, property string)

Source from the content-addressed store, hash-verified

525}
526
527func GetStringArrayProperty(body map[string]interface{}, property string) ([]string, error) {
528 if raw, exists := body[property]; !exists {
529 return nil, nil
530 } else if strings, ok := raw.([]string); ok {
531 return strings, nil
532 } else if items, ok := raw.([]interface{}); ok {
533 strings := make([]string, len(items))
534 for i := 0; i < len(items); i++ {
535 strings[i], ok = items[i].(string)
536 if !ok {
537 return nil, base.HTTPErrorf(http.StatusBadRequest, "%s must be a string array", property)
538 }
539 }
540 return strings, nil
541 } else {
542 return nil, base.HTTPErrorf(http.StatusBadRequest, "%s must be a string array", property)
543 }
544}

Callers 4

handleAllDocsMethod · 0.92
handleBulkGetMethod · 0.92
splitRevisionListFunction · 0.85
CalculateBytesMethod · 0.85

Calls 1

HTTPErrorfFunction · 0.92

Tested by

no test coverage detected