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

Method GetApps

api/datastore/postgres/postgres.go:219–246  ·  view source on GitHub ↗
(ctx context.Context, filter *models.AppFilter)

Source from the content-addressed store, hash-verified

217}
218
219func (ds *PostgresDatastore) GetApps(ctx context.Context, filter *models.AppFilter) ([]*models.App, error) {
220 res := []*models.App{}
221
222 filterQuery, args := buildFilterAppQuery(filter)
223 rows, err := ds.db.Query(fmt.Sprintf("SELECT DISTINCT * FROM apps %s", filterQuery), args...)
224 if err != nil {
225 return nil, err
226 }
227 defer rows.Close()
228
229 for rows.Next() {
230 var app models.App
231 err := scanApp(rows, &app)
232
233 if err != nil {
234 if err == sql.ErrNoRows {
235 return res, nil
236 }
237 return res, err
238 }
239 res = append(res, &app)
240 }
241
242 if err := rows.Err(); err != nil {
243 return res, err
244 }
245 return res, nil
246}
247
248func (ds *PostgresDatastore) InsertRoute(ctx context.Context, route *models.Route) (*models.Route, error) {
249 hbyte, err := json.Marshal(route.Headers)

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.80
buildFilterAppQueryFunction · 0.70
scanAppFunction · 0.70
NextMethod · 0.65

Tested by

no test coverage detected