Make DeleteReply() return count of affected rows.
This commit is contained in:
parent
506a010b23
commit
723d2d4772
@ -279,26 +279,26 @@ func (d *SQLiteDatabase) UpdateReply(reply *guestbook.Reply) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *SQLiteDatabase) DeleteReply(entryID int64) error {
|
||||
func (d *SQLiteDatabase) DeleteReply(entryID int64) (int64, error) {
|
||||
tx, err := d.db.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
return -1, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
res, err := tx.Stmt(stmtDeleteReply).Exec(entryID)
|
||||
if err != nil {
|
||||
return err
|
||||
return -1, err
|
||||
}
|
||||
|
||||
_, err = res.RowsAffected()
|
||||
ra, err := res.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
return -1, err
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
return nil
|
||||
return ra, nil
|
||||
}
|
||||
|
||||
func (d *SQLiteDatabase) Close() error {
|
||||
|
@ -7,9 +7,9 @@ type Guestbook interface {
|
||||
Count() (int64, error)
|
||||
NewEntry(entry *Entry) error
|
||||
UpdateEntry(entry *Entry) error
|
||||
DeleteEntry(entryID int64) error
|
||||
DeleteEntry(entryID int64) (int64, error)
|
||||
NewReply(reply *Reply) error
|
||||
UpdateReply(reply *Reply) error
|
||||
DeleteReply(entryID int64) error
|
||||
DeleteReply(entryID int64) (int64, error)
|
||||
Close() error
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user