pg

package
v0.0.0-...-e4bb11d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2016 License: MIT Imports: 8 Imported by: 0

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

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 NewDriver

func NewDriver(pgURL string) *Driver

NewDriver is for constructing correct driver instance

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

func (d *Driver) Begin() (interface{}, error)

Begin is for starting new transaction. It returns relevant to this driver state for transaction

func (*Driver) Commit

func (d *Driver) Commit(itx interface{}) error

Commit is for committing the 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) Exec

func (d *Driver) Exec(tx interface{}, query string, args ...interface{}) error

Exec is for executing query discarding its result

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

func (d *Driver) HasTransactions() bool

HasTransactions indicates transaction support of the driver

func (*Driver) Remove

func (d *Driver) Remove(tx interface{}, tablename string, ID field.Field) error

Remove is for removing existing record given its ID

func (*Driver) Rollback

func (d *Driver) Rollback(itx interface{})

Rollback is for rolling back the transaction

func (*Driver) Update

func (d *Driver) Update(tx interface{}, tablename string, fields []field.Field, ID field.Field) error

Update is for updating existing record given its ID and fields to update

func (*Driver) Where

func (d *Driver) Where(tablename string, fields []field.Field, ctx context.Context, where string, args ...interface{}) ([][]field.Field, error)

Where is for fetching specific records from current context given where query and arguments

Directories

Path Synopsis
Package auto allows one to setup rebecca/driver/pg in a convenient way from environment variables.
Package auto allows one to setup rebecca/driver/pg in a convenient way from environment variables.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL