mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-31 13: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
|
@ -152,3 +152,19 @@ func RunLimitedVariablesQuery(ctx context.Context, query string, qp QueryProvide
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// StatementList is a list of SQL statements to prepare and a pointer to where to store the resulting prepared statement.
|
||||
type StatementList []struct {
|
||||
Statement **sql.Stmt
|
||||
SQL string
|
||||
}
|
||||
|
||||
// Prepare the SQL for each statement in the list and assign the result to the prepared statement.
|
||||
func (s StatementList) Prepare(db *sql.DB) (err error) {
|
||||
for _, statement := range s {
|
||||
if *statement.Statement, err = db.Prepare(statement.SQL); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue