Delete removes a Link using its short name.
(short string)
| 135 | |
| 136 | // Delete removes a Link using its short name. |
| 137 | func (s *SQLiteDB) Delete(short string) error { |
| 138 | s.mu.Lock() |
| 139 | defer s.mu.Unlock() |
| 140 | |
| 141 | result, err := s.db.Exec("DELETE FROM Links WHERE ID = ?", linkID(short)) |
| 142 | if err != nil { |
| 143 | return err |
| 144 | } |
| 145 | rows, err := result.RowsAffected() |
| 146 | if err != nil { |
| 147 | return err |
| 148 | } |
| 149 | if rows != 1 { |
| 150 | return fmt.Errorf("expected to affect 1 row, affected %d", rows) |
| 151 | } |
| 152 | return nil |
| 153 | } |
| 154 | |
| 155 | // LoadStats returns click stats for links. |
| 156 | func (s *SQLiteDB) LoadStats() (ClickStats, error) { |