Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRecordNotFoundError ¶
IsRecordNotFoundError returns whether the given error is due to a requested record not present in the DB.
func NewRecordNotFoundError ¶
func NewRecordNotFoundError() error
NewRecordNotFoundError returns a ErrRecordNotFoundError.
Types ¶
type Config ¶
type Config struct { EnableLogging bool `configkey:"database.log"` // Whether to enable logging of the database InMemory bool `configkey:"database.inmemory" default:"false"` Host string `configkey:"database.host" validate:"required"` Port string `configkey:"database.port" validate:"required"` DbName string `configkey:"database.dbname" default:"postgres"` DbUser string `configkey:"database.dbuser" default:"postgres"` DbPassword string `configkey:"database.dbpassword" validate:"required"` ConnectionParams string `configkey:"database.connectionParams"` // Postgres sql connection parameters separate by space ConnectionLifetime time.Duration `configkey:"database.connectionLifeTime,duration" default:"1h"` }
Config contains the configuration parameter to set up the orm.
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
Migrator is a structure used to perform DB migrations.
func NewMigrator ¶
NewMigrator creates a new Migrator class. ex.) NewMigrator(orm, &model.Hoge{}, &model.Fuga{})
func (*Migrator) Initialize ¶
Initialize performs the migrations for the models handled by the Migrator.
func (*Migrator) IsInitialized ¶
IsInitialized returns whether the Migrator is initialized.
type ORM ¶
type ORM struct {
// contains filtered or unexported fields
}
ORM represent an Object Relational Mapper instance.
func (*ORM) GetDB ¶
GetDB returns the DB instance associated with the orm object. Panics if the object is not initialized.
func (*ORM) GetTableName ¶
GetTableName returns the name of the table for the given model. Assumes that the globalDB is initialized, returns empty string if not
func (*ORM) IsInitialized ¶
IsInitialized returns whether the orm is initialized.