New creates a new database store using a SQL database connection.
(sdb *sql.DB, opts ...func(*sqlQuerier))
| 56 | |
| 57 | // New creates a new database store using a SQL database connection. |
| 58 | func New(sdb *sql.DB, opts ...func(*sqlQuerier)) Store { |
| 59 | dbx := sqlx.NewDb(sdb, "postgres") |
| 60 | q := &sqlQuerier{ |
| 61 | db: dbx, |
| 62 | sdb: dbx, |
| 63 | // This is an arbitrary number. |
| 64 | serialRetryCount: 3, |
| 65 | } |
| 66 | |
| 67 | for _, opt := range opts { |
| 68 | opt(q) |
| 69 | } |
| 70 | return q |
| 71 | } |
| 72 | |
| 73 | // TxOptions is used to pass some execution metadata to the callers. |
| 74 | // Ideally we could throw this into a context, but no context is used for |
no outgoing calls