Self-review

This commit is contained in:
Kegan Dougal 2017-05-24 16:47:23 +01:00
parent b29725ab13
commit 4e0c1924a6
2 changed files with 11 additions and 10 deletions

View file

@ -54,7 +54,7 @@ const selectDeviceByTokenSQL = "" +
const deleteDeviceSQL = "" + const deleteDeviceSQL = "" +
"DELETE FROM devices WHERE id = $1 AND localpart = $2" "DELETE FROM devices WHERE id = $1 AND localpart = $2"
// TODO: List devices, delete device API // TODO: List devices?
type devicesStatements struct { type devicesStatements struct {
insertDeviceStmt *sql.Stmt insertDeviceStmt *sql.Stmt

View file

@ -75,6 +75,7 @@ func (d *Database) CreateDevice(localpart, deviceID string) (dev *authtypes.Devi
return return
} }
// TODO: factor out to common
func runTransaction(db *sql.DB, fn func(txn *sql.Tx) error) (err error) { func runTransaction(db *sql.DB, fn func(txn *sql.Tx) error) (err error) {
txn, err := db.Begin() txn, err := db.Begin()
if err != nil { if err != nil {