MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / GetSetFields

Function GetSetFields

internal/storage/db/couchbase/shared.go:13–41  ·  view source on GitHub ↗

GetSetFields to get set fields

(webhookMap map[string]interface{})

Source from the content-addressed store, hash-verified

11
12// GetSetFields to get set fields
13func GetSetFields(webhookMap map[string]interface{}) (string, map[string]interface{}) {
14 params := make(map[string]interface{}, 1)
15 updateFields := ""
16 for key, value := range webhookMap {
17 if key == "_id" {
18 continue
19 }
20 if key == "_key" {
21 continue
22 }
23 if value == nil {
24 updateFields += fmt.Sprintf("%s=$%s,", key, key)
25 params[key] = "null"
26 continue
27 }
28 valueType := reflect.TypeOf(value)
29 if valueType.Name() == "string" {
30 updateFields += fmt.Sprintf("%s = $%s, ", key, key)
31 params[key] = value.(string)
32
33 } else {
34 updateFields += fmt.Sprintf("%s = $%s, ", key, key)
35 params[key] = value
36 }
37 }
38 updateFields = strings.Trim(updateFields, " ")
39 updateFields = strings.TrimSuffix(updateFields, ",")
40 return updateFields, params
41}
42
43// GetTotalDocs to get total documents in a collection
44func (p *provider) GetTotalDocs(ctx context.Context, collection string) (int64, error) {

Callers 4

UpdateAuthenticatorMethod · 0.85
UpdateWebhookMethod · 0.85
UpdateEmailTemplateMethod · 0.85
UpdateUsersMethod · 0.85

Calls 1

NameMethod · 0.80

Tested by

no test coverage detected