Documentation ¶
Index ¶
- func AddConnectionsPool(poolName string, pool *pgxpool.Pool, migrationsPath string) error
- func Close()
- func DB(poolName string) *pgxpool.Pool
- func MigrationsPath(poolName string) string
- func NewConnectionPool(ctx context.Context, poolName string, connConfig *pgxpool.Config, ...) error
- func SetTimezone(ctx context.Context, poolName string, location *time.Location) error
- type Column
- type Model
- func (Model) Columns() string
- func (m *Model) Delete(ctx context.Context) error
- func (Model) PoolName() (name string)
- func (m *Model) Save(ctx context.Context) (err error)
- func (m *Model) Scan(src interface{}) error
- func (Model) ScanRow(rows pgx.Rows) (Modeler, error)
- func (Model) Table() string
- func (m Model) Value() (driver.Value, error)
- type Modeler
- type Pool
- func (p *Pool) BuildCount() (string, []interface{})
- func (p *Pool) BuildSelect() (string, []interface{})
- func (p *Pool) BuildSum(column string) (string, []interface{})
- func (p *Pool) Close()
- func (p *Pool) Columns(ctx context.Context) ([]Column, error)
- func (p *Pool) Count(ctx context.Context) (int64, error)
- func (p *Pool) Databases(ctx context.Context) ([]string, error)
- func (p *Pool) Delete(ctx context.Context) error
- func (p *Pool) Distinct(on ...string) *Pool
- func (p *Pool) EnumValues(ctx context.Context, name string) ([]string, error)
- func (p *Pool) Enums(ctx context.Context) (map[string][]string, error)
- func (p *Pool) Exists(ctx context.Context) (bool, error)
- func (p *Pool) First(ctx context.Context) (Modeler, error)
- func (p *Pool) FullJoin(table, alias, condition string) *Pool
- func (p *Pool) GroupBy(column string, columns ...string) *Pool
- func (p *Pool) GroupWhere(f func(p *Pool)) *Pool
- func (p *Pool) Insert(ctx context.Context, data map[string]interface{}) (id int64, err error)
- func (p *Pool) Join(table, alias, condition string) *Pool
- func (p *Pool) LeftJoin(table, alias, condition string) *Pool
- func (p *Pool) Limit(limit int) *Pool
- func (p *Pool) Offset(offset int) *Pool
- func (p *Pool) OrGroupWhere(f func(p *Pool)) *Pool
- func (p *Pool) OrWhere(column, operator string, value interface{}) *Pool
- func (p *Pool) OrWhereBetween(column string, from, to interface{}) *Pool
- func (p *Pool) OrWhereIn(column string, values *WhereInValues) *Pool
- func (p *Pool) OrWhereNotIn(column string, values *WhereInValues) *Pool
- func (p *Pool) OrWhereRaw(sql string, bindings ...interface{}) *Pool
- func (p *Pool) OrderBy(column, order string) *Pool
- func (p *Pool) OrderByRand() *Pool
- func (p *Pool) OrderByRaw(orderRaw string) *Pool
- func (p *Pool) Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
- func (p *Pool) RightJoin(table, alias, condition string) *Pool
- func (p *Pool) Select(ctx context.Context) (*Rows, error)
- func (p *Pool) Sum(ctx context.Context, column string) (float64, error)
- func (p *Pool) Tables(ctx context.Context) ([]string, error)
- func (p *Pool) Union(all bool, queries ...*Pool) *Pool
- func (p *Pool) Update(ctx context.Context, data map[string]interface{}) error
- func (p *Pool) Validation(ctx context.Context, data map[string]interface{}) (validData map[string]interface{}, err error)
- func (p *Pool) Where(column, operator string, value interface{}) *Pool
- func (p *Pool) WhereBetween(column string, from, to interface{}) *Pool
- func (p *Pool) WhereIn(column string, values *WhereInValues) *Pool
- func (p *Pool) WhereNotIn(column string, values *WhereInValues) *Pool
- func (p *Pool) WhereRaw(sql string, bindings ...interface{}) *Pool
- func (p *Pool) Write(ctx context.Context, data map[string]interface{}) (int64, error)
- type Rows
- type WhereInValues
- func (w *WhereInValues) Int(in ...int) *WhereInValues
- func (w *WhereInValues) Int64(in ...int64) *WhereInValues
- func (w *WhereInValues) Interface(in ...interface{}) *WhereInValues
- func (w *WhereInValues) Sql(args []interface{}) (string, []interface{})
- func (w *WhereInValues) String(in ...string) *WhereInValues
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConnectionsPool ¶
AddConnectionsPool Добавит существующее подключение в коллекцию
func MigrationsPath ¶
MigrationsPath Вернёт путь к директории с миграциями
Types ¶
type Model ¶
Model базовая модель соответствующая минимально требуемой структуре Modeler
type Modeler ¶
type Modeler interface { sql.Scanner driver.Valuer Table() string Columns() string PoolName() string ScanRow(rows pgx.Rows) (Modeler, error) Save(context.Context) error Delete(context.Context) error }
Modeler интерфейс модели
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool пул соединений
func (*Pool) BuildCount ¶
BuildCount Вернёт строку запроса и аргументы
func (*Pool) BuildSelect ¶
BuildSelect Вернёт строку запроса и аргументы
func (*Pool) EnumValues ¶
EnumValues Вернёт доступные значения для типа ENUM
func (*Pool) GroupWhere ¶
GroupWhere Добавит групповое условие WHERE через AND
func (*Pool) OrGroupWhere ¶
OrGroupWhere Добавит групповое условие WHERE через OR
func (*Pool) OrWhereBetween ¶
OrWhereBetween Добавит условие WHERE BETWEEN через OR
func (*Pool) OrWhereIn ¶
func (p *Pool) OrWhereIn(column string, values *WhereInValues) *Pool
OrWhereIn Добавит условие WHERE IN через OR
func (*Pool) OrWhereNotIn ¶
func (p *Pool) OrWhereNotIn(column string, values *WhereInValues) *Pool
OrWhereNotIn Добавит условие WHERE NOT IN через OR
func (*Pool) OrWhereRaw ¶
OrWhereRaw Произвольное условие WHERE через OR
func (*Pool) OrderByRand ¶
OrderByRand Отсортировать в случайном порядке
func (*Pool) OrderByRaw ¶
OrderByRaw Произвольная сортировка
func (*Pool) Validation ¶
func (p *Pool) Validation(ctx context.Context, data map[string]interface{}) (validData map[string]interface{}, err error)
Validation Валидация данных перед записью
func (*Pool) WhereBetween ¶
WhereBetween Добавит условие WHERE BETWEEN через AND
func (*Pool) WhereIn ¶
func (p *Pool) WhereIn(column string, values *WhereInValues) *Pool
WhereIn Добавит условие WHERE IN через AND
func (*Pool) WhereNotIn ¶
func (p *Pool) WhereNotIn(column string, values *WhereInValues) *Pool
WhereNotIn Добавит условие WHERE NOT IN через AND
type Rows ¶
type Rows struct { pgx.Rows // contains filtered or unexported fields }
Rows Интерфейс для хранения результата запроса к БД
type WhereInValues ¶
type WhereInValues struct {
// contains filtered or unexported fields
}
WhereInValues Адаптор для передачи слайсов, в запрос WHERE IN
func (*WhereInValues) Int ¶
func (w *WhereInValues) Int(in ...int) *WhereInValues
Int Загрузка ...int
func (*WhereInValues) Int64 ¶
func (w *WhereInValues) Int64(in ...int64) *WhereInValues
Int64 Загрузка ...int64
func (*WhereInValues) Interface ¶
func (w *WhereInValues) Interface(in ...interface{}) *WhereInValues
Interface Загрузка ...interface{}
func (*WhereInValues) Sql ¶
func (w *WhereInValues) Sql(args []interface{}) (string, []interface{})
Sql Вернёт подготовленную строку запроса и дополненный слайс аргументов
func (*WhereInValues) String ¶
func (w *WhereInValues) String(in ...string) *WhereInValues
String Загрузка ...string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
https://gist.github.com/regeda/969a067ff4ed6ffa8ed6
|
https://gist.github.com/regeda/969a067ff4ed6ffa8ed6 |