* GetApps retrieves an array of apps according to a specific filter. */
(ctx context.Context, filter *models.AppFilter)
| 238 | GetApps retrieves an array of apps according to a specific filter. |
| 239 | */ |
| 240 | func (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 | /* |
| 266 | InsertRoute inserts an route to MySQL. |
nothing calls this directly
no test coverage detected