Documentation ¶
Overview ¶
Package postgres contains repository implementations using PostgreSQL as the underlying database.
Index ¶
- func Connect(cfg Config) (*sqlx.DB, error)
- func NewGroupRepository(db Database) things.GroupRepository
- func NewProfileRepository(db Database) things.ProfileRepository
- func NewRolesRepository(db Database) things.RolesRepository
- func NewThingRepository(db Database) things.ThingRepository
- type Config
- type Database
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Connect ¶
Connect creates a connection to the PostgreSQL instance and applies any unapplied database migrations. A non-nil error is returned to indicate failure.
func NewGroupRepository ¶
func NewGroupRepository(db Database) things.GroupRepository
NewGroupRepository instantiates a PostgreSQL implementation of group repository.
func NewProfileRepository ¶ added in v0.24.0
func NewProfileRepository(db Database) things.ProfileRepository
NewProfileRepository instantiates a PostgreSQL implementation of profile repository.
func NewRolesRepository ¶
func NewRolesRepository(db Database) things.RolesRepository
NewRolesRepository instantiates a PostgreSQL implementation of roles repository.
func NewThingRepository ¶
func NewThingRepository(db Database) things.ThingRepository
NewThingRepository instantiates a PostgreSQL implementation of thing repository.
Types ¶
type Config ¶
type Config struct { Host string Port string User string Pass string Name string SSLMode string SSLCert string SSLKey string SSLRootCert string }
Config defines the options that are used when connecting to a PostgreSQL instance
type Database ¶
type Database interface { NamedExecContext(context.Context, string, interface{}) (sql.Result, error) QueryRowxContext(context.Context, string, ...interface{}) *sqlx.Row NamedQueryContext(context.Context, string, interface{}) (*sqlx.Rows, error) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error GetContext(context.Context, interface{}, string, ...interface{}) error BeginTxx(context.Context, *sql.TxOptions) (*sqlx.Tx, error) }
Database provides a database interface
func NewDatabase ¶
NewDatabase creates a ThingDatabase instance