Documentation ¶
Overview ¶
Wrapper that simplifies use of Golang ORM with focus on PostgreSQL
Package pgorm implements Golang ORM with focus on PostgreSQL features and performance. See https://github.com/go-pg/pg
Index ¶
- func GenerateCertificate(host, destDir, organization string) error
- func LoadCertificate(pgOptions *pg.Options) error
- type Database
- func (d *Database) Close()
- func (d *Database) CreateModel(model interface{}) error
- func (d *Database) DeleteModel(model interface{}) error
- func (d *Database) DropTable(model interface{}) error
- func (d *Database) Error(where string, message string, err error)
- func (d *Database) Fatal(where string, message string, err error)
- func (d *Database) GetAllModels(model interface{}) error
- func (d *Database) GetAllWithCondition(model interface{}, condition interface{}, args ...interface{}) error
- func (d *Database) GetModel(model interface{}) error
- func (d *Database) GetWithCondition(model interface{}, condition interface{}, args ...interface{}) error
- func (d *Database) Info(where string, message string)
- func (d *Database) SaveModel(model interface{}) error
- func (d *Database) Success(where string, message string)
- func (d *Database) UpdateModel(model interface{}) error
- func (d *Database) Warn(where string, message string)
- type IChange
- type IClose
- type IDatabase
- type IGet
- type ILogger
- type Model
- func (m *Model) AutoMigrateAll() error
- func (m *Model) Count() int
- func (m *Model) DropTables() error
- func (m *Model) IsOpen() bool
- func (m *Model) OpenWithConfig(user, database, password string, cfg []byte) error
- func (m *Model) OpenWithDefault(user, database, password string) error
- func (m *Model) Register(values ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCertificate ¶
Generate a self-signed X.509 certificate for a TLS server. Outputs to 'pgorm-cert.pem' and 'pgorm-key.pem' and will overwrite existing files.
host = "", "Comma-separated hostnames and IPs to generate a certificate for" validFrom = "start-date", "", "Creation date formatted as Jan 1 15:04:05 2011" validFor = "duration", 365*24*time.Hour, "Duration that certificate is valid for" isCA = "ca", false, "whether this cert should be its own Certificate Authority" rsaBits = "rsa-bits", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set" ecdsaCurve = "ecdsa-curve", "", "ECDSA curve to use to generate a key. Valid values are P224, P256 (recommended), P384, P521"
Types ¶
type Database ¶
Database implements the PostgreSQL ORM
func (*Database) CreateModel ¶
CreateModel attempts add the given model to database.
func (*Database) DeleteModel ¶
DeleteModel attempts update the given model in the database.
func (*Database) GetAllModels ¶
GetAllModels attempts retrieve all models based on the given model from the database.
func (*Database) GetAllWithCondition ¶
func (d *Database) GetAllWithCondition(model interface{}, condition interface{}, args ...interface{}) error
GetAllWithCondition attempts retrieve all models based on the given model and condition from the database.
func (*Database) GetWithCondition ¶
func (d *Database) GetWithCondition(model interface{}, condition interface{}, args ...interface{}) error
GetWithCondition attempts retrieve a model based on the given model and condition from the database.
func (*Database) UpdateModel ¶
UpdateModel attempts update the given model in the database.
type IChange ¶
type IChange interface { SaveModel(model interface{}) error UpdateModel(model interface{}) error DeleteModel(model interface{}) error CreateModel(model interface{}) error DropTable(model interface{}) error }
IChange defines the change related methods
type IGet ¶
type IGet interface { GetModel(model interface{}) error GetAllModels(model interface{}) error GetWithCondition(model interface{}, condition interface{}, args ...interface{}) error GetAllWithCondition(model interface{}, condition interface{}, args ...interface{}) error }
IGet defines the get related methods
type ILogger ¶
type ILogger interface { Success(where string, message string) Info(where string, message string) Warn(where string, message string) Error(where string, message string, err error) Fatal(where string, message string, err error) }
ILogger defines the logging related methods
type Model ¶
Model facilitate database interactions, supports postgres, mysql and foundation
func (*Model) AutoMigrateAll ¶
AutoMigrateAll runs migrations for all the registered models
func (*Model) DropTables ¶
DropTables Drops All Model Database Tables
func (*Model) IsOpen ¶
IsOpen returns true if the Model has already established connection to the database
func (*Model) OpenWithConfig ¶
OpenWithConfig - opens database connection with the incoming settings, if bad cfg income - use default cfg
func (*Model) OpenWithDefault ¶
OpenWithConfig - opens database connection with the incoming settings, if bad cfg income - use default cfg