GetSetFields to get set fields
(webhookMap map[string]interface{})
| 11 | |
| 12 | // GetSetFields to get set fields |
| 13 | func 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 |
| 44 | func (p *provider) GetTotalDocs(ctx context.Context, collection string) (int64, error) { |
no test coverage detected