Пример #1
0
func finish(db repo.DB, todo *Todo) error {
	_, err := db.Exec("update todo set finished = ? where id = ?", true, todo.ID)
	if err != nil {
		return err
	}

	todo.Finished = true
	return nil
}
Пример #2
0
func countByFinished(db repo.DB, finished bool) (int, error) {
	var n int
	err := db.QueryRow("select count(*) from todo where finished = ?", finished).Scan(&n)
	return n, err
}
Пример #3
0
func delete(db repo.DB, todo *Todo) error {
	_, err := db.Exec("delete from todo where id = ?", todo.ID)
	return err
}