Documentation ¶
Overview ¶
Package postgres provides an implementation of the lockbox.dev/clients.Storer interface that stores data in a PostgreSQL database.
The package assumes that the database is set up and ready for its use, and does not automatically set up the database itself. Migrations to set the database up are available in the sql folder of this package. The migrations are also available in the migrations package, which contains the contents of the sql folder packaged using go-bindata to make them easy to include in Go binaries. Migrations should be applied in lexicographical order, with numbers coming before letters.
Index ¶
- Constants
- type Client
- type Factory
- type RedirectURI
- type Storer
- func (s Storer) AddRedirectURIs(ctx context.Context, uris []clients.RedirectURI) error
- func (s Storer) Create(ctx context.Context, client clients.Client) error
- func (s Storer) Delete(ctx context.Context, id string) error
- func (s Storer) Get(ctx context.Context, id string) (clients.Client, error)
- func (s Storer) ListRedirectURIs(ctx context.Context, clientID string) ([]clients.RedirectURI, error)
- func (s Storer) RemoveRedirectURIs(ctx context.Context, uris []string) error
- func (s Storer) Update(ctx context.Context, id string, change clients.Change) error
Constants ¶
const (
TestConnStringEnvVar = "PG_TEST_DB"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ID string `sql_column:"id"` Name string `sql_column:"name"` SecretHash string `sql_column:"secret_hash"` SecretScheme string `sql_column:"secret_scheme"` Confidential bool `sql_column:"confidential"` CreatedAt time.Time `sql_column:"created_at"` CreatedBy string `sql_column:"created_by"` CreatedByIP string `sql_column:"created_by_ip"` }
func (Client) GetSQLTableName ¶
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
func NewFactory ¶
func (*Factory) TeardownStorers ¶
type RedirectURI ¶
type RedirectURI struct { ID string `sql_column:"id"` URI string `sql_column:"uri"` IsBaseURI bool `sql_column:"is_base_uri"` ClientID string `sql_column:"client_id"` CreatedAt time.Time `sql_column:"created_at"` CreatedBy string `sql_column:"created_by"` CreatedByIP string `sql_column:"created_by_ip"` }
func (RedirectURI) GetSQLTableName ¶
func (p RedirectURI) GetSQLTableName() string
type Storer ¶
type Storer struct {
// contains filtered or unexported fields
}
Postgres is an implementation of the Storer interface that stores data in a PostgreSQL database.
func NewStorer ¶
NewPostgres returns a Postgres instance that is backed by the specified *sql.DB. The returned Postgres instance is ready to be used as a Storer.
func (Storer) AddRedirectURIs ¶
func (Storer) ListRedirectURIs ¶
func (Storer) RemoveRedirectURIs ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package migrations provides access to the SQL migrations used to set up a PostgreSQL database for the postgres Storer implementation.
|
Package migrations provides access to the SQL migrations used to set up a PostgreSQL database for the postgres Storer implementation. |