Documentation ¶
Overview ¶
Package pg provides implementation of rebecca driver for postgres. It uses github.com/lib/pq and database/sql under the hood.
Enabling this driver for rebecca:
First import both `rebecca` and `pg` in your main.go (or in your test suite):
import ( "github.com/waterlink/rebecca" "github.com/waterlink/rebecca/driver/pg" )
Then in your top level func (`main` or `TestMain`):
d := pg.NewDriver("postgres://user:pass@host:port/database?sslmode=sslmode") rebecca.SetupDriver(d)
The same can be done through environment variables with package https://godoc.org/github.com/waterlink/rebecca/driver/pg/auto
Index ¶
- type Driver
- func (d *Driver) All(tablename string, fields []field.Field, ctx context.Context) ([][]field.Field, error)
- func (d *Driver) Begin() (interface{}, error)
- func (d *Driver) Commit(itx interface{}) error
- func (d *Driver) Create(tx interface{}, tablename string, fields []field.Field, ID *field.Field) error
- func (d *Driver) Exec(tx interface{}, query string, args ...interface{}) error
- func (d *Driver) First(tablename string, fields []field.Field, ctx context.Context, where string, ...) ([]field.Field, error)
- func (d *Driver) Get(tx interface{}, tablename string, fields []field.Field, ID field.Field) ([]field.Field, error)
- func (d *Driver) HasTransactions() bool
- func (d *Driver) Remove(tx interface{}, tablename string, ID field.Field) error
- func (d *Driver) Rollback(itx interface{})
- func (d *Driver) Update(tx interface{}, tablename string, fields []field.Field, ID field.Field) error
- func (d *Driver) Where(tablename string, fields []field.Field, ctx context.Context, where string, ...) ([][]field.Field, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements rebecca.Driver interface
func (*Driver) All ¶
func (d *Driver) All(tablename string, fields []field.Field, ctx context.Context) ([][]field.Field, error)
All is for fetching all records in current context
func (*Driver) Begin ¶
Begin is for starting new transaction. It returns relevant to this driver state for transaction
func (*Driver) Create ¶
func (d *Driver) Create(tx interface{}, tablename string, fields []field.Field, ID *field.Field) error
Create is for creating new record and updating its ID
func (*Driver) First ¶
func (d *Driver) First(tablename string, fields []field.Field, ctx context.Context, where string, args ...interface{}) ([]field.Field, error)
First is for fetching only first specific record from current context matching given where query and arguments
func (*Driver) Get ¶
func (d *Driver) Get(tx interface{}, tablename string, fields []field.Field, ID field.Field) ([]field.Field, error)
Get is for fetching one record given its ID
func (*Driver) HasTransactions ¶
HasTransactions indicates transaction support of the driver
func (*Driver) Rollback ¶
func (d *Driver) Rollback(itx interface{})
Rollback is for rolling back the transaction