postgres¶
import "github.com/go-rel/postgres"
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)
Constants¶
const Name string = "postgres"
const TimeLayout = "2006-01-02 15:04:05.999999999Z07:00:00"
func FormatTime¶
func FormatTime(t time.Time) string
func MustOpen¶
func MustOpen(dsn string) rel.Adapter
func New¶
func New(database *db.DB) rel.Adapter
func Open¶
func Open(dsn string) (rel.Adapter, error)
type Postgres¶
type Postgres struct {
sql.SQL
}
func (Postgres) Begin¶
func (p Postgres) Begin(ctx context.Context) (rel.Adapter, error)
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)
func (Postgres) InsertAll¶
func (p Postgres) InsertAll(ctx context.Context, query rel.Query, primaryField string, fields []string, bulkMutates []map[string]rel.Mutate, onConflict rel.OnConflict) ([]interface{}, error)
func (Postgres) Name¶
func (Postgres) Name() string
type Quote¶
type Quote struct{}
func (Quote) ID¶
func (q Quote) ID(name string) string
func (Quote) Value¶
func (q Quote) Value(v interface{}) string
type ValueConvert¶
type ValueConvert struct{}
func (ValueConvert) ConvertValue¶
func (c ValueConvert) ConvertValue(v interface{}) (driver.Value, error)
Last update: 2024-08-16