MCPcopy
hub / github.com/iron-io/functions / buildFilterRouteQuery

Function buildFilterRouteQuery

api/datastore/postgres/postgres.go:525–548  ·  view source on GitHub ↗
(filter *models.RouteFilter)

Source from the content-addressed store, hash-verified

523}
524
525func buildFilterRouteQuery(filter *models.RouteFilter) (string, []interface{}) {
526 if filter == nil {
527 return "", nil
528 }
529 var b bytes.Buffer
530 var args []interface{}
531
532 where := func(colOp, val string) {
533 if val != "" {
534 args = append(args, val)
535 if len(args) == 1 {
536 fmt.Fprintf(&b, "WHERE %s $1", colOp)
537 } else {
538 fmt.Fprintf(&b, " AND %s $%d", colOp, len(args))
539 }
540 }
541 }
542
543 where("path =", filter.Path)
544 where("app_name =", filter.AppName)
545 where("image =", filter.Image)
546
547 return b.String(), args
548}
549
550func (ds *PostgresDatastore) Put(ctx context.Context, key, value []byte) error {
551 _, err := ds.db.Exec(`

Callers 2

GetRoutesMethod · 0.70
GetRoutesByAppMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…