Documentation
¶
Overview ¶
Package pgmodel provides a generalized way of working with Postgres rows. Implementing the PGModel interface allows you to utilize the get, save, and delete functions without having to write repetitive query strings.
Index ¶
- func Delete(pm PGModel, t *pg.Tx) (orm.Result, error)
- func Get(pm PGModel, t *pg.Tx, queryKey string, queryValue interface{}) (orm.Result, error)
- func GetMany(pm []PGModel, t *pg.Tx, queryKey string, queryValue interface{}) (orm.Result, error)
- func Save(pm PGModel, t *pg.Tx) (orm.Result, error)
- type PGModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type PGModel ¶
type PGModel interface { // The model's primary key. PrimaryKey() string // The value of the model's primary key. PrimaryKeyValue() interface{} // The schema name of the model's table. SchemaName() string // The model's table name. TableName() string // The total number of columns in the table. ColumnCount() int // An array of non-primary key column names. NonPKColumns() []string // An array of non-primary key values in the same order as the columns defined // by NonPKColumns. NonPKValues() []interface{} // Converts the model's slice from column, c, to a string value. // // This method's return value should be a stirng appropriate for a query. I.e. // if the value in column c is the slice of floats, [0.1, 0.2, 0.3], then the // method should return the string // // {0.1, 0.2, 0.3} // // whereas if the value in c is the byte slice [0xA3, 0xA4, 0xA5], then the // method should return // // a3a4a5 ConvertSlice(c string) string }
PGModel interface types implement methods that describe their table.
Click to show internal directories.
Click to hide internal directories.