Documentation ¶
Overview ¶
Package postgres wraps postgres (pq) driver as an adapter for REL.
Usage:
// open postgres connection. adapter, err := postgres.Open("postgres://postgres@localhost/rel_test?sslmode=disable") if err != nil { panic(err) } defer adapter.Close() // initialize REL's repo. repo := rel.New(adapter)
Index ¶
- Constants
- func FormatTime(t time.Time) string
- func MustOpen(dsn string) rel.Adapter
- func New(database *db.DB) rel.Adapter
- func Open(dsn string) (rel.Adapter, error)
- type Postgres
- func (p Postgres) Begin(ctx context.Context) (rel.Adapter, error)
- func (p Postgres) Insert(ctx context.Context, query rel.Query, primaryField string, ...) (interface{}, error)
- func (p Postgres) InsertAll(ctx context.Context, query rel.Query, primaryField string, fields []string, ...) ([]interface{}, error)
- func (Postgres) Name() string
- type Quote
- type ValueConvert
Constants ¶
View Source
const Name string = "postgres"
Name of database type this adapter implements.
View Source
const TimeLayout = "2006-01-02 15:04:05.999999999Z07:00:00"
TimeLayout used by PostgreSQL adapter.
Variables ¶
This section is empty.
Functions ¶
func FormatTime ¶ added in v0.5.0
FormatTime formats time to PostgreSQL format.
Types ¶
type Postgres ¶
Postgres adapter.
func (Postgres) Insert ¶
func (p Postgres) Insert(ctx context.Context, query rel.Query, primaryField string, mutates map[string]rel.Mutate, onConflict rel.OnConflict) (interface{}, error)
Insert inserts a record to database and returns its id.
type ValueConvert ¶ added in v0.2.0
type ValueConvert struct{}
ValueConvert converts values to PostgreSQL literals.
func (ValueConvert) ConvertValue ¶ added in v0.2.0
func (c ValueConvert) ConvertValue(v interface{}) (driver.Value, error)
Click to show internal directories.
Click to hide internal directories.