Documentation ¶
Index ¶
- type DataObject
- type DatabaseConnection
- func (db *DatabaseConnection) Close() error
- func (db *DatabaseConnection) CreateSchema() error
- func (db *DatabaseConnection) CreateTable(obj DataObject) error
- func (db *DatabaseConnection) DropSchema() error
- func (db *DatabaseConnection) DropTable(obj DataObject) error
- func (db *DatabaseConnection) GetRelationshipIDs(fkName string, fkValue int, relList interface{}) ([]int, error)
- func (db *DatabaseConnection) Populate(obj DataObject, index int) error
- func (db *DatabaseConnection) Save(obj DataObject) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataObject ¶
type DataObject interface { Save(*DatabaseConnection) error SaveRecursive(*DatabaseConnection) error GetByID(*DatabaseConnection, int) error GetByIDRecursive(*DatabaseConnection, int) error }
DataObject is defines the requirement of structs to be used with this package. Currently this interface is empty, but may be used in the future.
type DatabaseConnection ¶
type DatabaseConnection struct { Schema string // contains filtered or unexported fields }
DatabaseConnection represents an open DB connection
func Open ¶
func Open(uds string) (*DatabaseConnection, error)
Open opens a DB connection using the same user/db/schema
func OpenDebug ¶
func OpenDebug(uds string) (*DatabaseConnection, error)
OpenDebug opens a DB connection using the same user/db/schema and enables outputing debug messages
func OpenVerbose ¶
func OpenVerbose(user, database, schema string, debug bool) (*DatabaseConnection, error)
OpenVerbose opens a DB allowing to specify different user/db/schema and enable debug log output
func (*DatabaseConnection) Close ¶
func (db *DatabaseConnection) Close() error
Close closes the db connection
func (*DatabaseConnection) CreateSchema ¶
func (db *DatabaseConnection) CreateSchema() error
CreateSchema will create the schema of the DatabaseConnection
func (*DatabaseConnection) CreateTable ¶
func (db *DatabaseConnection) CreateTable(obj DataObject) error
CreateTable will create a new table based upon the DataObject given
func (*DatabaseConnection) DropSchema ¶
func (db *DatabaseConnection) DropSchema() error
DropSchema will drop the schema of the DatabaseConnection
func (*DatabaseConnection) DropTable ¶
func (db *DatabaseConnection) DropTable(obj DataObject) error
DropTable will drop the table related the given DataObject
func (*DatabaseConnection) GetRelationshipIDs ¶
func (db *DatabaseConnection) GetRelationshipIDs(fkName string, fkValue int, relList interface{}) ([]int, error)
GetRelationshipIDs will return a list of FK values of a relationship, as well as fill the given list with empty structs of that object to the same size as the returned ID list
func (*DatabaseConnection) Populate ¶
func (db *DatabaseConnection) Populate(obj DataObject, index int) error
Populate fills the given DataObject with the info from the DB with PK of index
func (*DatabaseConnection) Save ¶
func (db *DatabaseConnection) Save(obj DataObject) error
Save creates or updates a DB entry for the given DataObject. Create/Update logic is based on the PK being > 0 for updates.