Documentation
¶
Index ¶
- Variables
- type BaseRecord
- type BaseTxRunner
- func (tx *BaseTxRunner) Commit(ctx context.Context) error
- func (tx *BaseTxRunner) Exec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)
- func (tx *BaseTxRunner) Prepare(ctx context.Context, name, query string) (*pgconn.StatementDescription, error)
- func (tx *BaseTxRunner) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (tx *BaseTxRunner) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, ...) (pgconn.CommandTag, error)
- func (tx *BaseTxRunner) QueryRow(ctx context.Context, query string, args ...interface{}) pgx.Row
- func (tx *BaseTxRunner) Rollback(ctx context.Context) error
- type ConnectionPgx
- type DefaultScoper
- type HookAfterDelete
- type HookAfterInsert
- type HookAfterSave
- type HookAfterUpdate
- type HookBeforeDelete
- type HookBeforeInsert
- type HookBeforeSave
- type HookBeforeUpdate
- type JoinType
- type PgxDBProxy
- type PgxDBRunner
- type PgxExecer
- type PgxPreparer
- type PgxQueryer
- type PgxRowQueryer
- type Query
- type Record
- type ResultSet
- type ResultSetPgx
- type Schema
- type SchemaField
- type TxPgxProxy
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrFieldNotFound = errors.New("field not found")
)
View Source
var ErrInvalidJoinType = errors.New("invalid join type")
Functions ¶
This section is empty.
Types ¶
type BaseRecord ¶
type BaseRecord struct {
// contains filtered or unexported fields
}
BaseRecord implements some basic methods to be used by the store.
func (*BaseRecord) IsPersisted ¶
func (record *BaseRecord) IsPersisted() bool
IsPersisted returns if the record was persisted.
func (*BaseRecord) IsWritable ¶
func (record *BaseRecord) IsWritable() bool
IsWritable returns if the record can be saved to the database.
func (*BaseRecord) TableName ¶
func (record *BaseRecord) TableName() string
TableName returns the name of the table that this record repesents.
type BaseTxRunner ¶
type BaseTxRunner struct {
// contains filtered or unexported fields
}
func (*BaseTxRunner) Exec ¶
func (tx *BaseTxRunner) Exec(ctx context.Context, query string, args ...interface{}) (pgconn.CommandTag, error)
func (*BaseTxRunner) Prepare ¶
func (tx *BaseTxRunner) Prepare(ctx context.Context, name, query string) (*pgconn.StatementDescription, error)
func (*BaseTxRunner) QueryFunc ¶
func (tx *BaseTxRunner) QueryFunc(ctx context.Context, sql string, args []interface{}, scans []interface{}, f func(pgx.QueryFuncRow) error) (pgconn.CommandTag, error)
type ConnectionPgx ¶
type ConnectionPgx interface {
PgxDBRunner
DB() PgxDBProxy
Builder() sqlf.Builder
Begin(ctx context.Context) (TxPgxProxy, error)
BeginTx(ctx context.Context, opts pgx.TxOptions) (TxPgxProxy, error)
}
func NewConnectionPgx ¶
func NewConnectionPgx(db *pgxpool.Pool, builder sqlf.Builder) ConnectionPgx
NewConnectionPgx will create a new instance of the `*BaseConnection`.
type DefaultScoper ¶
type DefaultScoper interface {
DefaultScope() error
}
type HookAfterDelete ¶
type HookAfterInsert ¶
type HookAfterInsert interface {
AfterInsert(ctx context.Context, err error, fields ...SchemaField)
}
type HookAfterSave ¶
type HookAfterSave interface {
AfterSave(ctx context.Context, err error, fields ...SchemaField)
}
type HookAfterUpdate ¶
type HookAfterUpdate interface {
AfterUpdate(ctx context.Context, err error, fields ...SchemaField)
}
type HookBeforeDelete ¶
type HookBeforeInsert ¶
type HookBeforeInsert interface {
BeforeInsert(ctx context.Context, fields ...SchemaField) error
}
type HookBeforeSave ¶
type HookBeforeSave interface {
BeforeSave(ctx context.Context, fields ...SchemaField) error
}
type HookBeforeUpdate ¶
type HookBeforeUpdate interface {
BeforeUpdate(ctx context.Context, fields ...SchemaField) error
}
type PgxDBProxy ¶
type PgxDBRunner ¶
type PgxDBRunner interface {
PgxExecer
PgxQueryer
PgxRowQueryer
PgxPreparer
}
type PgxPreparer ¶
type PgxQueryer ¶
type PgxRowQueryer ¶
type Query ¶
type Query interface {
sqlf.FastSqlizer
sqlf.Sqlizer
// Select defines what are the fields that this query should return. If this method is called twice, the second time
// will override all values from the first call. If you want to stack fields, use `AddSelect` instead.
Select(fields ...SchemaField)
// AddSelect adds the passed fields to the select list.
AddSelect(fields ...SchemaField)
// GetSelect returns the fields that where selected.
GetSelect() []SchemaField
// From defines the FROM clause for the Query
From(schema Schema)
// Join adds a join to the Query.
Join(joinType JoinType, schema Schema, condition string, params ...interface{})
// Join adds a inner join to the Query.
InnerJoin(schema Schema, condition string, params ...interface{})
// Join adds a left join to the Query.
LeftJoin(schema Schema, condition string, params ...interface{})
// Join adds a right join to the Query.
RightJoin(schema Schema, condition string, params ...interface{})
// Join adds a full join to the Query.
FullJoin(schema Schema, condition string, params ...interface{})
// Where define the where condition for the Query.
Where(condition string, params ...interface{})
// WhereCriteria define the where condition for the Query using criteria.
WhereCriteria(conditions ...sqlf.FastSqlizer)
// Skip sets the skip option for the Query.
Skip(skip int)
// Limit defines the pagination for the Query.
Limit(limit int)
// GroupBy defines the GROUP BY clause for the Query.
GroupBy(fields ...interface{})
// GroupByX defines the GROUP BY with the HAVING clause for the Query.
GroupByX(func(sqlf.GroupBy))
// OrderBy defines the ORDER BY for the Query.
OrderBy(fields ...interface{})
// OrderBy defines the ORDER BY for the Query.
OrderByX(f func(sqlf.OrderBy))
}
func NewQuery ¶
func NewQuery(conn ConnectionPgx, schema Schema) Query
type ResultSetPgx ¶
type ResultSetPgx interface {
ResultSet
Close()
FieldDescriptions() []pgproto3.FieldDescription
}
type Schema ¶
type Schema interface {
// Table returns the table name for this schema.
Table() string
// Alias returns the alias name for the table. By default, its implementation
// should return the table name.
Alias() string
// As returns a new Schema with an SQL alias set.
As(alias string) Schema
// Columns list all columns from this schema.
Columns() []SchemaField
}
Schema represents a table schema.
func NewSchema ¶
func NewSchema(table string, fields ...SchemaField) Schema
type SchemaField ¶
type SchemaField interface {
fmt.Stringer
// Name returns the name of the field
Name() string
// QualifiedName returns the field name together with the Schema table name.
QualifiedName(Schema) string
}
SchemaField represents a field in the schema.
func NewSchemaField ¶
func NewSchemaField(name string) SchemaField
type TxPgxProxy ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.