Documentation
¶
Index ¶
- Constants
- type DB
- func (db *DB) CreateSchema(modelsList []interface{}, dropExisting bool) error
- func (db *DB) CreateTable(model interface{}) error
- func (db *DB) Delete(m interfaces.Model) error
- func (db *DB) DropTable(model interface{}) error
- func (db *DB) Get(m interfaces.Model, ID interface{}) error
- func (db *DB) Insert(m interfaces.Model) error
- func (db *DB) Query(mList interface{}, model interfaces.Model, query []string) error
- func (db *DB) QueryOne(m interfaces.Model, query string) error
- func (db *DB) RawQuery(mList interface{}, model interfaces.Model, rawQuery []string) error
- func (db *DB) Update(m interfaces.Model) error
Constants ¶
const ( // ETABLEEXISTS happens when a table already exists ETABLEEXISTS = "ERROR #42P07" // ENOROWS happens when no result was found ENOROWS = "pg: no rows in result set" // EMULTIPLEROWS happens when multiple results where found with QueryOne EMULTIPLEROWS = "pg: multiple rows in result set" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB defines a PostgreSQL database that will use go-pg as an ORM
func NewFromURL ¶ added in v0.4.1
NewFromURL returns a new PG Database instance
func (*DB) CreateSchema ¶
CreateSchema creates the database tables if dropExisting is set to true it will drop the current schema
func (*DB) CreateTable ¶
CreateTable creates a new table in the database
func (*DB) Delete ¶
func (db *DB) Delete(m interfaces.Model) error
Delete removes an existing model from the database
func (*DB) Get ¶
func (db *DB) Get(m interfaces.Model, ID interface{}) error
Get returns a single model from the database using its primary key
func (*DB) Insert ¶
func (db *DB) Insert(m interfaces.Model) error
Insert adds a model into the database
func (*DB) Query ¶
func (db *DB) Query(mList interface{}, model interfaces.Model, query []string) error
Query returns a list of models from the database that satisfy a Query, extra parameters in the Query allow for Limit and Offset
func (*DB) QueryOne ¶
func (db *DB) QueryOne(m interfaces.Model, query string) error
QueryOne returns a single model from the database that satisfies a Query. The method will return an error if there is more than one result from the query