Documentation ¶
Index ¶
- Variables
- func IsQueryBuilderSetClauseError(err error) bool
- func KeyAccessServerProtoJSON(keyAccessServerJSON []byte) ([]*kasr.KeyAccessServer, error)
- func MarshalCreateMetadata(metadata *common.MetadataMutable) ([]byte, *common.Metadata, error)
- func MarshalUpdateMetadata(m *common.MetadataMutable, b common.MetadataUpdateEnum, ...) ([]byte, *common.Metadata, error)
- func NewStatementBuilder() sq.StatementBuilderType
- func NewTableWithSchema(schema string) func(name string) Table
- func NewUniqueAlreadyExistsError(value string) error
- func WrapIfKnownInvalidQueryErr(err error) error
- type Client
- func (c *Client) Close()
- func (c Client) Exec(ctx context.Context, sql string, args []interface{}) error
- func (c *Client) MigrationDown(ctx context.Context) error
- func (c *Client) MigrationStatus(ctx context.Context) ([]*goose.MigrationStatus, error)
- func (c Client) Query(ctx context.Context, sql string, args []interface{}) (pgx.Rows, error)
- func (c Client) QueryRow(ctx context.Context, sql string, args []interface{}) (pgx.Row, error)
- func (c *Client) RunMigrations(ctx context.Context) (int, error)
- type Config
- type DbError
- type PgxIface
- type Table
Constants ¶
This section is empty.
Variables ¶
View Source
var NewTable func(name string) Table
Functions ¶
func KeyAccessServerProtoJSON ¶
func KeyAccessServerProtoJSON(keyAccessServerJSON []byte) ([]*kasr.KeyAccessServer, error)
func MarshalCreateMetadata ¶
func MarshalUpdateMetadata ¶
func NewStatementBuilder ¶
func NewStatementBuilder() sq.StatementBuilderType
Postgres uses $1, $2, etc. for placeholders
func NewTableWithSchema ¶
func WrapIfKnownInvalidQueryErr ¶
Get helpful error message for PostgreSQL violation
Types ¶
type Client ¶
type Client struct { Pgx PgxIface // This is the stdlib connection that is used for transactions SqlDB *sql.DB // contains filtered or unexported fields }
func (*Client) MigrationStatus ¶
type Config ¶
type Config struct { Host string `yaml:"host" default:"localhost"` Port int `yaml:"port" default:"5432"` Database string `yaml:"database" default:"opentdf"` User string `yaml:"user" default:"postgres"` Password string `yaml:"password" default:"changeme"` RunMigrations bool `yaml:"runMigrations" default:"true"` SSLMode string `yaml:"sslmode" default:"prefer"` Schema string `yaml:"schema" default:"opentdf"` }
type DbError ¶
type DbError string
const ( ErrUniqueConstraintViolation DbError = "ErrUniqueConstraintViolation: value must be unique" ErrNotNullViolation DbError = "ErrNotNullViolation: value cannot be null" ErrForeignKeyViolation DbError = "ErrForeignKeyViolation: value is referenced by another table" ErrRestrictViolation DbError = "ErrRestrictViolation: value cannot be deleted due to restriction" ErrNotFound DbError = "ErrNotFound: value not found" ErrEnumValueInvalid DbError = "ErrEnumValueInvalid: not a valid enum value" ErrUuidInvalid DbError = "ErrUuidInvalid: value not a valid UUID" ErrFqnMissingValue DbError = "ErrFqnMissingValue: FQN must include a value" ErrMissingValue DbError = "ErrMissingValue: value must be included" )
type PgxIface ¶
type PgxIface interface { Acquire(ctx context.Context) (*pgxpool.Conn, error) Exec(context.Context, string, ...any) (pgconn.CommandTag, error) QueryRow(context.Context, string, ...any) pgx.Row Query(context.Context, string, ...any) (pgx.Rows, error) Ping(context.Context) error Close() Config() *pgxpool.Config }
We can rename this but wanted to get mocks working.
Click to show internal directories.
Click to hide internal directories.