postgres

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncProvider

type FuncProvider struct {
	DB        *sql.DB
	TableName string
}

FuncProvider implements dbProvider for PostgreSQL.

Methods defined on the FuncProvider perform JSON (un)marshalling where appropriate to ensure a fair comparison as the mgo driver does this automatically. Ideally we'd want ot just read the data and not perform an (un)marshalling on the client side but this is a fair compromise.

func NewProvider

func NewProvider(endpoint *url.URL, tableName string) (*FuncProvider, error)

NewProvider returns an instance of FuncProvider.

func (*FuncProvider) GetMaxID

func (p *FuncProvider) GetMaxID() (uint64, error)

GetMaxID returns the highest ID in the table.

func (*FuncProvider) InsertRecord

func (p *FuncProvider) InsertRecord(data *record.Person, id idgen.Generator, rnd *rand.Rand) bool

InsertRecord generates a new random record and inserts it with an ID provided by id.GetNew as a JSON-encoded string.

func (*FuncProvider) ReadMostRecentRecord

func (p *FuncProvider) ReadMostRecentRecord(_ *record.Person, _ idgen.Generator, _ *rand.Rand) bool

ReadMostRecentRecord fetches the most recently inserted record by performing a sort on the ID field, and limiting the results to a single record.

func (*FuncProvider) ReadRange

func (p *FuncProvider) ReadRange(_ *record.Person, _ idgen.Generator, _ *rand.Rand) bool

ReadRange performs a range query on the age field.

THe query attempts to fetch all records where age is greater than 45 and less than 75.

func (*FuncProvider) ReadRecord

func (p *FuncProvider) ReadRecord(_ *record.Person, id idgen.Generator, _ *rand.Rand) bool

ReadRecord attempts to fetch the record with an ID returned by id.GetExisting.

func (*FuncProvider) UpdateRecord

func (p *FuncProvider) UpdateRecord(_ *record.Person, id idgen.Generator, rnd *rand.Rand) bool

UpdateRecord attempts to update the record with ID returned by id.GetExisting.

The balance field is changed to a random value from rnd using jsonb_set.

Jump to

Keyboard shortcuts

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