diff options
author | Kegsay <kegan@matrix.org> | 2020-05-26 18:23:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-26 18:23:39 +0100 |
commit | 19aa44ecaef70a2be7294e8ad738467da41d1f2e (patch) | |
tree | e823357e7de9fad4bd20b39a4efb7d72975d3743 /roomserver/storage/postgres/transactions_table.go | |
parent | 803af87dc49f6db57019892215c6c6cf049b5c50 (diff) |
Convert transactions/rooms table to share more code (#1063)
* Convert rooms table
* Convert transactions table
* Convert rooms table and factor out lots of functions
* I think you'll be needing this..
Diffstat (limited to 'roomserver/storage/postgres/transactions_table.go')
-rw-r--r-- | roomserver/storage/postgres/transactions_table.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/roomserver/storage/postgres/transactions_table.go b/roomserver/storage/postgres/transactions_table.go index 87c1caca..7f7ef76a 100644 --- a/roomserver/storage/postgres/transactions_table.go +++ b/roomserver/storage/postgres/transactions_table.go @@ -18,6 +18,8 @@ package postgres import ( "context" "database/sql" + + "github.com/matrix-org/dendrite/roomserver/storage/tables" ) const transactionsSchema = ` @@ -51,20 +53,21 @@ type transactionStatements struct { selectTransactionEventIDStmt *sql.Stmt } -func (s *transactionStatements) prepare(db *sql.DB) (err error) { - _, err = db.Exec(transactionsSchema) +func NewPostgresTransactionsTable(db *sql.DB) (tables.Transactions, error) { + s := &transactionStatements{} + _, err := db.Exec(transactionsSchema) if err != nil { - return + return nil, err } - return statementList{ + return s, statementList{ {&s.insertTransactionStmt, insertTransactionSQL}, {&s.selectTransactionEventIDStmt, selectTransactionEventIDSQL}, }.prepare(db) } -func (s *transactionStatements) insertTransaction( - ctx context.Context, +func (s *transactionStatements) InsertTransaction( + ctx context.Context, txn *sql.Tx, transactionID string, sessionID int64, userID string, @@ -76,7 +79,7 @@ func (s *transactionStatements) insertTransaction( return } -func (s *transactionStatements) selectTransactionEventID( +func (s *transactionStatements) SelectTransactionEventID( ctx context.Context, transactionID string, sessionID int64, |