Fetch fetches results of the check with given name.
(name string)
| 134 | |
| 135 | // Fetch fetches results of the check with given name. |
| 136 | func (sql Storage) Fetch(name string) ([]types.Result, error) { |
| 137 | db, err := sql.dbConnect() |
| 138 | if err != nil { |
| 139 | return nil, err |
| 140 | } |
| 141 | defer db.Close() |
| 142 | |
| 143 | var checkResult []byte |
| 144 | var results []types.Result |
| 145 | |
| 146 | err = db.Get(&checkResult, `SELECT results FROM "checks" WHERE name=$1 LIMIT 1`, name) |
| 147 | if err != nil { |
| 148 | return nil, err |
| 149 | } |
| 150 | if err = json.Unmarshal(checkResult, &results); err != nil { |
| 151 | return nil, err |
| 152 | } |
| 153 | return results, nil |
| 154 | } |
| 155 | |
| 156 | // Store stores results in the database. |
| 157 | func (sql Storage) Store(results []types.Result) error { |