mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 22:22:46 +00:00
Factor out StatementList to sqlutil
and use it in userapi
It helps with the boilerplate.
This commit is contained in:
parent
9e4618000e
commit
ed4097825b
43 changed files with 145 additions and 264 deletions
|
@ -81,26 +81,15 @@ func (s *accountsStatements) execSchema(db *sql.DB) error {
|
|||
}
|
||||
|
||||
func (s *accountsStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerName) (err error) {
|
||||
if s.insertAccountStmt, err = db.Prepare(insertAccountSQL); err != nil {
|
||||
return
|
||||
}
|
||||
if s.updatePasswordStmt, err = db.Prepare(updatePasswordSQL); err != nil {
|
||||
return
|
||||
}
|
||||
if s.deactivateAccountStmt, err = db.Prepare(deactivateAccountSQL); err != nil {
|
||||
return
|
||||
}
|
||||
if s.selectAccountByLocalpartStmt, err = db.Prepare(selectAccountByLocalpartSQL); err != nil {
|
||||
return
|
||||
}
|
||||
if s.selectPasswordHashStmt, err = db.Prepare(selectPasswordHashSQL); err != nil {
|
||||
return
|
||||
}
|
||||
if s.selectNewNumericLocalpartStmt, err = db.Prepare(selectNewNumericLocalpartSQL); err != nil {
|
||||
return
|
||||
}
|
||||
s.serverName = server
|
||||
return
|
||||
return sqlutil.StatementList{
|
||||
{&s.insertAccountStmt, insertAccountSQL},
|
||||
{&s.updatePasswordStmt, updatePasswordSQL},
|
||||
{&s.deactivateAccountStmt, deactivateAccountSQL},
|
||||
{&s.selectAccountByLocalpartStmt, selectAccountByLocalpartSQL},
|
||||
{&s.selectPasswordHashStmt, selectPasswordHashSQL},
|
||||
{&s.selectNewNumericLocalpartStmt, selectNewNumericLocalpartSQL},
|
||||
}.Prepare(db)
|
||||
}
|
||||
|
||||
// insertAccount creates a new account. 'hash' should be the password hash for this account. If it is missing,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue