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

Method GetApps

api/datastore/mysql/mysql.go:240–263  ·  view source on GitHub ↗

* GetApps retrieves an array of apps according to a specific filter. */

(ctx context.Context, filter *models.AppFilter)

Source from the content-addressed store, hash-verified

238GetApps retrieves an array of apps according to a specific filter.
239*/
240func (ds *MySQLDatastore) GetApps(ctx context.Context, filter *models.AppFilter) ([]*models.App, error) {
241 res := []*models.App{}
242 filterQuery, args := buildFilterAppQuery(filter)
243 rows, err := ds.db.Query(fmt.Sprintf("SELECT DISTINCT name, config FROM apps %s", filterQuery), args...)
244 if err != nil {
245 return nil, err
246 }
247 defer rows.Close()
248
249 for rows.Next() {
250 var app models.App
251 err := scanApp(rows, &app)
252
253 if err != nil {
254 break
255 }
256 res = append(res, &app)
257 }
258
259 if err := rows.Err(); err != nil {
260 return res, err
261 }
262 return res, nil
263}
264
265/*
266InsertRoute inserts an route to MySQL.

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