pg

package module
v0.0.0-...-fa50c16 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2015 License: MIT Imports: 9 Imported by: 1 module, 9 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pg

Go (golang) and PostgreSQL easy integration

Warning: This package is a work in progress and the APIs are subject to change. Consider this a v0 project.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERecordNotFound  = errors.New("Record not found")
	EMultipleResults = errors.New("Unexpected multiple results from query")
)

Functions

This section is empty.

Types

type Entity

type Entity interface {
	Result
	Table() string
	OrderBy() string
}

func NewEntity

func NewEntity(e Entity) Entity

type EntityHandler

type EntityHandler interface {
	Create(entity Entity) error
	FindOne(entity Entity, where string, whereParams ...interface{}) (Entity, error)
	FindAll(entity Entity, where string, whereParams ...interface{}) ([]Entity, error)
	Update(entity Entity) error
	Delete(entity Entity) error
}

type JSONB

type JSONB null.String

func (*JSONB) Decode

func (j *JSONB) Decode(dst interface{}) error

func (*JSONB) Encode

func (j *JSONB) Encode(src interface{}) error

func (*JSONB) MarshalJSON

func (j *JSONB) MarshalJSON() ([]byte, error)

MarshalJSON implements the `json.Marshaller` interface

func (*JSONB) UnmarshalJSON

func (j *JSONB) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the `json.Unmarshaler` interface

type Result

type Result interface{}

func NewResult

func NewResult(r Result) Result

type ResultHandler

type ResultHandler interface {
	Query(result Result, sql string, params ...interface{}) ([]Result, error)
}

type Session

type Session struct {
	DB *sql.DB
}

Session implements the EntityHandler and the ResultHandler interface

func NewSession

func NewSession(connectionString string) (*Session, error)

func (*Session) Create

func (s *Session) Create(entity Entity) error

func (*Session) Delete

func (s *Session) Delete(entity Entity) error

func (*Session) Exec

func (s *Session) Exec(query string, args ...interface{}) (sql.Result, error)

func (*Session) FindAll

func (s *Session) FindAll(entity Entity, where string, whereParams ...interface{}) ([]Entity, error)

func (*Session) FindOne

func (s *Session) FindOne(entity Entity, where string, whereParams ...interface{}) (Entity, error)

func (*Session) Query

func (s *Session) Query(result Result, sql string, params ...interface{}) ([]Result, error)

func (*Session) Tx

func (s *Session) Tx() (*Tx, error)

func (*Session) Update

func (s *Session) Update(entity Entity) error

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx implements the EntityHandler and the ResultHandler interfaces

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Create

func (t *Tx) Create(entity Entity) error

func (*Tx) Delete

func (t *Tx) Delete(entity Entity) error

func (*Tx) Exec

func (t *Tx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*Tx) FindAll

func (t *Tx) FindAll(entity Entity, where string, whereParams ...interface{}) ([]Entity, error)

func (*Tx) FindOne

func (t *Tx) FindOne(entity Entity, where string, whereParams ...interface{}) (Entity, error)

func (*Tx) Query

func (t *Tx) Query(result Result, sql string, params ...interface{}) ([]Result, error)

func (*Tx) Rollback

func (t *Tx) Rollback() error

func (*Tx) Update

func (t *Tx) Update(entity Entity) error

Jump to

Keyboard shortcuts

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