Documentation
¶
Overview ¶
Package pgorm implements Golang ORM with focus on PostgreSQL features and performance. See https://github.com/go-pg/pg
Index ¶
- type Database
- func (d *Database) Close()
- func (d *Database) DeleteModel(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) GetRowsWithCondition(model interface{}, condition interface{}, args ...interface{}) error
- func (d *Database) GetWithCondition(model interface{}, condition interface{}, args ...interface{}) error
- func (d *Database) Info(where string, message string)
- func (d *Database) Open()
- func (d *Database) OpenWithOptions(opts *pg.Options)
- 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 IConn
- type IDatabase
- type IGet
- type ILogger
- type Model
- func (m *Model) AutoMigrateAll(migrate bool)
- func (m *Model) Count() int
- func (m *Model) DropTables(drop bool, verbose bool)
- func (m *Model) IsOpen() bool
- func (m *Model) OpenWithConfig(cfg *config.Config) error
- func (m *Model) OpenWithParams(conn string, migrate bool, drop bool, nomodel bool) error
- func (m *Model) Register(values ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
Database implements the PostgreSQL ORM
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) GetRowsWithCondition ¶
func (d *Database) GetRowsWithCondition(model interface{}, condition interface{}, args ...interface{}) error
GetRowsWithCondition attempts retrieve a model 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) OpenWithOptions ¶
OpenWithOptions
func (*Database) UpdateModel ¶
UpdateModel attempts update the given model in the database.
type IChange ¶
type IChange interface {
SaveModel(interface{}) error
UpdateModel(interface{}) error
DeleteModel(interface{}) error
}
IChange defines the change related methods
type IConn ¶
type IConn interface {
Open() error
OpenWithConnString(conn string) error
OpenWithEnv() error
OpenWithOptions(opts *pg.Options) error
Close() error
}
IConn defines the connection related methods
type IGet ¶
type IGet interface {
GetModel(interface{}) error
GetAllModels(interface{})
GetWithCondition(model interface{}, condition interface{}, args ...interface{}) error
GetAllWithCondition(model interface{}, condition interface{}, args ...interface{}) error
GetRowsWithCondition(interface{}, interface{}, ...interface{}) error
}
IGet defines the get related methods
type ILogger ¶
type ILogger interface {
Success(where string, message string, err error)
Info(where string, message string, err error)
Warn(where string, message string, err error)
Error(where string, message string, err error)
Fatal(where string, message string, err error)
}
ILogger defines the logging related methods
type Model ¶
type Model struct {
*Database
// contains filtered or unexported fields
}
Model facilitate database interactions, supports postgres, mysql and foundation
func NewModel ¶
func NewModel() *Model
NewModel returns a new Model without opening database connection
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 settings found in cfg
func (*Model) OpenWithParams ¶
Settings: Database Database string `json:"database" yaml:"database" toml:"database" hcl:"database"` DatabaseConn string `json:"database_conn" yaml:"database_conn" toml:"database_conn" hcl:"database_conn"` Automigrate bool `json:"automigrate" yaml:"automigrate" toml:"automigrate" hcl:"automigrate"` DropTables bool `json:"droptables" yaml:"droptables" toml:"droptables" hcl:"droptables"` NoModel bool `json:"no_model" yaml:"no_model" toml:"no_model" hcl:"no_model"`