package orm

Import Path
	github.com/go-pg/pg/v10/orm (on go.dev)

Dependency Relation
	imports 24 packages, and imported by 2 packages


Package-Level Type Names (total 72, in which 40 are exported)
/* sort exporteds by: | */
( AfterDeleteHook) AfterDelete(context.Context) error Discard Model (interface) TableModel (interface)
( AfterInsertHook) AfterInsert(context.Context) error Discard Model (interface) TableModel (interface)
( AfterScanHook) AfterScan(context.Context) error Discard Model (interface) TableModel (interface)
( AfterSelectHook) AfterSelect(context.Context) error Discard Model (interface) TableModel (interface)
( AfterUpdateHook) AfterUpdate(context.Context) error Discard Model (interface) TableModel (interface)
( BeforeDeleteHook) BeforeDelete(context.Context) (context.Context, error) Discard Model (interface) TableModel (interface)
( BeforeInsertHook) BeforeInsert(context.Context) (context.Context, error) Discard Model (interface) TableModel (interface)
( BeforeScanHook) BeforeScan(context.Context) error
( BeforeUpdateHook) BeforeUpdate(context.Context) (context.Context, error) Discard Model (interface) TableModel (interface)
ColumnScanner is used to scan column values. Scan assigns a column value from a row. An error should be returned if the value can not be stored without loss of information. Discard *github.com/go-pg/pg/v10.Ints *github.com/go-pg/pg/v10.IntSet *github.com/go-pg/pg/v10.Strings func Discard.NextColumnScanner() ColumnScanner func HooklessModel.NextColumnScanner() ColumnScanner func Model.NextColumnScanner() ColumnScanner func TableModel.NextColumnScanner() ColumnScanner func github.com/go-pg/pg/v10.Scan(values ...interface{}) ColumnScanner func github.com/go-pg/pg/v10.(*Ints).NextColumnScanner() ColumnScanner func github.com/go-pg/pg/v10.(*IntSet).NextColumnScanner() ColumnScanner func github.com/go-pg/pg/v10.(*Strings).NextColumnScanner() ColumnScanner func Discard.AddColumnScanner(ColumnScanner) error func HooklessModel.AddColumnScanner(ColumnScanner) error func Model.AddColumnScanner(ColumnScanner) error func TableModel.AddColumnScanner(ColumnScanner) error func github.com/go-pg/pg/v10.Ints.AddColumnScanner(_ ColumnScanner) error func github.com/go-pg/pg/v10.IntSet.AddColumnScanner(_ ColumnScanner) error func github.com/go-pg/pg/v10.Strings.AddColumnScanner(_ ColumnScanner) error
// replaces PostgreSQL data type `text` with `varchar(n)` func NewCreateCompositeQuery(q *Query, opt *CreateCompositeOptions) *CreateCompositeQuery func (*Query).CreateComposite(opt *CreateCompositeOptions) error
(*CreateCompositeQuery) AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) (*CreateCompositeQuery) AppendTemplate(b []byte) ([]byte, error) (*CreateCompositeQuery) Clone() QueryCommand (*CreateCompositeQuery) Operation() QueryOp (*CreateCompositeQuery) Query() *Query (*CreateCompositeQuery) String() string *CreateCompositeQuery : QueryAppender *CreateCompositeQuery : QueryCommand *CreateCompositeQuery : TemplateAppender *CreateCompositeQuery : expvar.Var *CreateCompositeQuery : fmt.Stringer func NewCreateCompositeQuery(q *Query, opt *CreateCompositeOptions) *CreateCompositeQuery
FKConstraints causes CreateTable to create foreign key constraints for has one relations. ON DELETE hook can be added using tag `pg:"on_delete:RESTRICT"` on foreign key field. ON UPDATE hook can be added using tag `pg:"on_update:CASCADE"` IfNotExists bool Temp bool // replaces PostgreSQL data type `text` with `varchar(n)` func NewCreateTableQuery(q *Query, opt *CreateTableOptions) *CreateTableQuery func (*Query).CreateTable(opt *CreateTableOptions) error
(*CreateTableQuery) AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) (*CreateTableQuery) AppendTemplate(b []byte) ([]byte, error) (*CreateTableQuery) Clone() QueryCommand (*CreateTableQuery) Operation() QueryOp (*CreateTableQuery) Query() *Query (*CreateTableQuery) String() string *CreateTableQuery : QueryAppender *CreateTableQuery : QueryCommand *CreateTableQuery : TemplateAppender *CreateTableQuery : expvar.Var *CreateTableQuery : fmt.Stringer func NewCreateTableQuery(q *Query, opt *CreateTableOptions) *CreateTableQuery
DB is a common interface for pg.DB and pg.Tx types. ( DB) Context() context.Context ( DB) CopyFrom(r io.Reader, query interface{}, params ...interface{}) (Result, error) ( DB) CopyTo(w io.Writer, query interface{}, params ...interface{}) (Result, error) ( DB) Exec(query interface{}, params ...interface{}) (Result, error) ( DB) ExecContext(c context.Context, query interface{}, params ...interface{}) (Result, error) ( DB) ExecOne(query interface{}, params ...interface{}) (Result, error) ( DB) ExecOneContext(c context.Context, query interface{}, params ...interface{}) (Result, error) ( DB) Formatter() QueryFormatter ( DB) Model(model ...interface{}) *Query ( DB) ModelContext(c context.Context, model ...interface{}) *Query ( DB) Query(model, query interface{}, params ...interface{}) (Result, error) ( DB) QueryContext(c context.Context, model, query interface{}, params ...interface{}) (Result, error) ( DB) QueryOne(model, query interface{}, params ...interface{}) (Result, error) ( DB) QueryOneContext(c context.Context, model, query interface{}, params ...interface{}) (Result, error) *github.com/go-pg/pg/v10.Conn *github.com/go-pg/pg/v10.DB *github.com/go-pg/pg/v10.Tx func NewQuery(db DB, model ...interface{}) *Query func NewQueryContext(ctx context.Context, db DB, model ...interface{}) *Query func (*Query).DB(db DB) *Query
(*DeleteQuery) AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) (*DeleteQuery) AppendTemplate(b []byte) ([]byte, error) (*DeleteQuery) Clone() QueryCommand (*DeleteQuery) Operation() QueryOp (*DeleteQuery) Query() *Query (*DeleteQuery) String() string *DeleteQuery : QueryAppender *DeleteQuery : QueryCommand *DeleteQuery : TemplateAppender *DeleteQuery : expvar.Var *DeleteQuery : fmt.Stringer func NewDeleteQuery(q *Query) *DeleteQuery
( Discard) AddColumnScanner(ColumnScanner) error ( Discard) AfterDelete(ctx context.Context) error ( Discard) AfterInsert(ctx context.Context) error ( Discard) AfterScan(ctx context.Context) error ( Discard) AfterSelect(ctx context.Context) error ( Discard) AfterUpdate(ctx context.Context) error ( Discard) BeforeDelete(ctx context.Context) (context.Context, error) ( Discard) BeforeInsert(ctx context.Context) (context.Context, error) ( Discard) BeforeUpdate(ctx context.Context) (context.Context, error) ( Discard) Init() error ( Discard) NextColumnScanner() ColumnScanner ( Discard) ScanColumn(col types.ColumnInfo, rd types.Reader, n int) error Discard : AfterDeleteHook Discard : AfterInsertHook Discard : AfterScanHook Discard : AfterSelectHook Discard : AfterUpdateHook Discard : BeforeDeleteHook Discard : BeforeInsertHook Discard : BeforeUpdateHook Discard : ColumnScanner Discard : HooklessModel Discard : Model var github.com/go-pg/pg/v10.Discard
Cascade bool IfExists bool func NewDropCompositeQuery(q *Query, opt *DropCompositeOptions) *DropCompositeQuery func (*Query).DropComposite(opt *DropCompositeOptions) error
(*DropCompositeQuery) AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) (*DropCompositeQuery) AppendTemplate(b []byte) ([]byte, error) (*DropCompositeQuery) Clone() QueryCommand (*DropCompositeQuery) Operation() QueryOp (*DropCompositeQuery) Query() *Query (*DropCompositeQuery) String() string *DropCompositeQuery : QueryAppender *DropCompositeQuery : QueryCommand *DropCompositeQuery : TemplateAppender *DropCompositeQuery : expvar.Var *DropCompositeQuery : fmt.Stringer func NewDropCompositeQuery(q *Query, opt *DropCompositeOptions) *DropCompositeQuery
Cascade bool IfExists bool func NewDropTableQuery(q *Query, opt *DropTableOptions) *DropTableQuery func (*Query).DropTable(opt *DropTableOptions) error
(*DropTableQuery) AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) (*DropTableQuery) AppendTemplate(b []byte) ([]byte, error) (*DropTableQuery) Clone() QueryCommand (*DropTableQuery) Operation() QueryOp (*DropTableQuery) Query() *Query (*DropTableQuery) String() string *DropTableQuery : QueryAppender *DropTableQuery : QueryCommand *DropTableQuery : TemplateAppender *DropTableQuery : expvar.Var *DropTableQuery : fmt.Stringer func NewDropTableQuery(q *Query, opt *DropTableOptions) *DropTableQuery
// escaped SQL name, e.g. "id" Default types.Safe Field reflect.StructField // struct field name, e.g. Id Index []int OnDelete string OnUpdate string // SQL name, .e.g. id SQLType string Type reflect.Type UserSQLType string (*Field) AppendValue(b []byte, strct reflect.Value, quote int) []byte (*Field) Clone() *Field (*Field) HasZeroValue(strct reflect.Value) bool (*Field) NullZero() bool (*Field) ScanValue(strct reflect.Value, rd types.Reader, n int) error (*Field) Value(strct reflect.Value) reflect.Value func (*Field).Clone() *Field func (*Table).GetField(name string) (*Field, error) func (*Table).AddField(field *Field) func (*Table).RemoveField(field *Field)
(*Formatter) FormatQuery(dst []byte, query string, params ...interface{}) []byte (*Formatter) FormatQueryBytes(dst, query []byte, params ...interface{}) []byte (*Formatter) Param(param string) interface{} (*Formatter) String() string (*Formatter) WithModel(model interface{}) *Formatter (*Formatter) WithParam(param string, value interface{}) *Formatter (*Formatter) WithTableModel(model TableModel) *Formatter *Formatter : QueryFormatter *Formatter : expvar.Var *Formatter : fmt.Stringer func NewFormatter() *Formatter func (*Formatter).WithModel(model interface{}) *Formatter func (*Formatter).WithParam(param string, value interface{}) *Formatter func (*Formatter).WithTableModel(model TableModel) *Formatter
AddColumnScanner adds the ColumnScanner to the model. Init is responsible to initialize/reset model state. It is called only once no matter how many rows were returned. NextColumnScanner returns a ColumnScanner that is used to scan columns from the current row. It is called once for every row. Discard Model (interface) TableModel (interface) *github.com/go-pg/pg/v10.Ints *github.com/go-pg/pg/v10.IntSet *github.com/go-pg/pg/v10.Strings
(*InsertQuery) AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) (*InsertQuery) AppendTemplate(b []byte) ([]byte, error) (*InsertQuery) Clone() QueryCommand (*InsertQuery) Operation() QueryOp (*InsertQuery) Query() *Query (*InsertQuery) String() string *InsertQuery : QueryAppender *InsertQuery : QueryCommand *InsertQuery : TemplateAppender *InsertQuery : expvar.Var *InsertQuery : fmt.Stringer func NewInsertQuery(q *Query) *InsertQuery
Index int (*Method) AppendValue(dst []byte, strct reflect.Value, quote int) []byte (*Method) Has(flag int8) bool (*Method) Value(strct reflect.Value) reflect.Value
AddColumnScanner adds the ColumnScanner to the model. ( Model) AfterDelete(context.Context) error ( Model) AfterInsert(context.Context) error ( Model) AfterScan(context.Context) error ( Model) AfterSelect(context.Context) error ( Model) AfterUpdate(context.Context) error ( Model) BeforeDelete(context.Context) (context.Context, error) ( Model) BeforeInsert(context.Context) (context.Context, error) ( Model) BeforeUpdate(context.Context) (context.Context, error) Init is responsible to initialize/reset model state. It is called only once no matter how many rows were returned. NextColumnScanner returns a ColumnScanner that is used to scan columns from the current row. It is called once for every row. Discard TableModel (interface) Model : AfterDeleteHook Model : AfterInsertHook Model : AfterScanHook Model : AfterSelectHook Model : AfterUpdateHook Model : BeforeDeleteHook Model : BeforeInsertHook Model : BeforeUpdateHook Model : HooklessModel func NewModel(value interface{}) (Model, error) func Result.Model() Model func github.com/go-pg/pg/v10.Result.Model() Model
AllWithDeleted changes query to return all rows including soft deleted ones. (*Query) AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) Apply calls the fn passing the Query as an argument. Clone clones the Query. Column adds a column to the Query quoting it according to PostgreSQL rules. Does not expand params like ?TableAlias etc. ColumnExpr can be used to bypass quoting restriction or for params expansion. Column name can be: - column_name, - table_alias.column_name, - table_alias.*. ColumnExpr adds column expression to the Query. (*Query) Context(c context.Context) *Query CopyFrom is an alias from DB.CopyFrom. CopyTo is an alias from DB.CopyTo. Count returns number of rows matching the query using count aggregate function. CountEstimate uses EXPLAIN to get estimated number of rows returned the query. If that number is bigger than the threshold it returns the estimation. Otherwise it executes another query using count aggregate function and returns the result. Based on https://wiki.postgresql.org/wiki/Count_estimate (*Query) CreateComposite(opt *CreateCompositeOptions) error (*Query) CreateTable(opt *CreateTableOptions) error (*Query) DB(db DB) *Query Delete deletes the model. When model has deleted_at column the row is soft deleted instead. Deleted adds `WHERE deleted_at IS NOT NULL` clause for soft deleted models. (*Query) Distinct() *Query (*Query) DistinctOn(expr string, params ...interface{}) *Query (*Query) DropComposite(opt *DropCompositeOptions) error (*Query) DropTable(opt *DropTableOptions) error (*Query) Except(other *Query) *Query (*Query) ExceptAll(other *Query) *Query ExcludeColumn excludes a column from the list of to be selected columns. Exec is an alias for DB.Exec. ExecOne is an alias for DB.ExecOne. Exists returns true or false depending if there are any rows matching the query. First sorts rows by primary key and selects the first row. It is a shortcut for: q.OrderExpr("id ASC").Limit(1) (*Query) For(s string, params ...interface{}) *Query ForEach calls the function for each row returned by the query without loading all rows into the memory. Function can accept a struct, a pointer to a struct, an orm.Model, or values for the columns in a row. Function must return an error. Delete forces delete of the model with deleted_at column. (*Query) Group(columns ...string) *Query (*Query) GroupExpr(group string, params ...interface{}) *Query (*Query) Having(having string, params ...interface{}) *Query Insert inserts the model. (*Query) Intersect(other *Query) *Query (*Query) IntersectAll(other *Query) *Query (*Query) Join(join string, params ...interface{}) *Query JoinOn appends join condition to the last join. (*Query) JoinOnOr(condition string, params ...interface{}) *Query Last sorts rows by primary key and selects the last row. It is a shortcut for: q.OrderExpr("id DESC").Limit(1) (*Query) Limit(n int) *Query (*Query) Model(model ...interface{}) *Query New returns new zero Query bound to the current db. (*Query) Offset(n int) *Query (*Query) OnConflict(s string, params ...interface{}) *Query Order adds sort order to the Query quoting column name. Does not expand params like ?TableAlias etc. OrderExpr can be used to bypass quoting restriction or for params expansion. Order adds sort order to the Query. Query is an alias for DB.Query. QueryOne is an alias for DB.QueryOne. Relation adds a relation to the query. Relation name can be: - RelationName to select all columns, - RelationName.column_name, - RelationName._ to join relation without selecting relation columns. Returning adds a RETURNING clause to the query. `Returning("NULL")` can be used to suppress default returning clause generated by go-pg for INSERT queries to get values for null columns. Select selects the model. SelectAndCount runs Select and Count in two goroutines, waits for them to finish and returns the result. If query limit is -1 it does not select any data and only counts the results. SelectAndCountEstimate runs Select and CountEstimate in two goroutines, waits for them to finish and returns the result. If query limit is -1 it does not select any data and only counts the results. SelectOrInsert selects the model inserting one if it does not exist. It returns true when model was inserted. (*Query) Set(set string, params ...interface{}) *Query (*Query) Table(tables ...string) *Query (*Query) TableExpr(expr string, params ...interface{}) *Query (*Query) TableModel() TableModel (*Query) Union(other *Query) *Query (*Query) UnionAll(other *Query) *Query Update updates the model. Update updates the model omitting fields with zero values such as: - empty string, - 0, - zero time, - empty map or slice, - byte array with all zeroes, - nil ptr, - types with method `IsZero() == true`. Value overwrites model value for the column in INSERT and UPDATE queries. (*Query) Where(condition string, params ...interface{}) *Query WhereGroup encloses conditions added in the function in parentheses. q.Where("TRUE"). WhereGroup(func(q *pg.Query) (*pg.Query, error) { q = q.WhereOr("FALSE").WhereOr("TRUE"). return q, nil }) generates WHERE TRUE AND (FALSE OR TRUE) WhereIn is a shortcut for Where and pg.In. WhereInMulti is a shortcut for Where and pg.InMulti. WhereInOr is a shortcut for WhereOr and pg.In. WhereGroup encloses conditions added in the function in parentheses. q.Where("TRUE"). WhereNotGroup(func(q *pg.Query) (*pg.Query, error) { q = q.WhereOr("FALSE").WhereOr("TRUE"). return q, nil }) generates WHERE TRUE AND NOT (FALSE OR TRUE) (*Query) WhereOr(condition string, params ...interface{}) *Query WhereOrGroup encloses conditions added in the function in parentheses. q.Where("TRUE"). WhereOrGroup(func(q *pg.Query) (*pg.Query, error) { q = q.Where("FALSE").Where("TRUE"). return q, nil }) generates WHERE TRUE OR (FALSE AND TRUE) WhereOrGroup encloses conditions added in the function in parentheses. q.Where("TRUE"). WhereOrGroup(func(q *pg.Query) (*pg.Query, error) { q = q.Where("FALSE").Where("TRUE"). return q, nil }) generates WHERE TRUE OR NOT (FALSE AND TRUE) WherePK adds condition based on the model primary keys. Usually it is the same as: Where("id = ?id") With adds subq as common table expression with the given name. (*Query) WithDelete(name string, subq *Query) *Query (*Query) WithInsert(name string, subq *Query) *Query (*Query) WithUpdate(name string, subq *Query) *Query WrapWith creates new Query and adds to it current query as common table expression with the given name. *Query : QueryAppender func NewQuery(db DB, model ...interface{}) *Query func NewQueryContext(ctx context.Context, db DB, model ...interface{}) *Query func (*CreateCompositeQuery).Query() *Query func (*CreateTableQuery).Query() *Query func DB.Model(model ...interface{}) *Query func DB.ModelContext(c context.Context, model ...interface{}) *Query func (*DeleteQuery).Query() *Query func (*DropCompositeQuery).Query() *Query func (*DropTableQuery).Query() *Query func (*InsertQuery).Query() *Query func (*Query).AllWithDeleted() *Query func (*Query).Apply(fn func(*Query) (*Query, error)) *Query func (*Query).Clone() *Query func (*Query).Column(columns ...string) *Query func (*Query).ColumnExpr(expr string, params ...interface{}) *Query func (*Query).Context(c context.Context) *Query func (*Query).DB(db DB) *Query func (*Query).Deleted() *Query func (*Query).Distinct() *Query func (*Query).DistinctOn(expr string, params ...interface{}) *Query func (*Query).Except(other *Query) *Query func (*Query).ExceptAll(other *Query) *Query func (*Query).ExcludeColumn(columns ...string) *Query func (*Query).For(s string, params ...interface{}) *Query func (*Query).Group(columns ...string) *Query func (*Query).GroupExpr(group string, params ...interface{}) *Query func (*Query).Having(having string, params ...interface{}) *Query func (*Query).Intersect(other *Query) *Query func (*Query).IntersectAll(other *Query) *Query func (*Query).Join(join string, params ...interface{}) *Query func (*Query).JoinOn(condition string, params ...interface{}) *Query func (*Query).JoinOnOr(condition string, params ...interface{}) *Query func (*Query).Limit(n int) *Query func (*Query).Model(model ...interface{}) *Query func (*Query).New() *Query func (*Query).Offset(n int) *Query func (*Query).OnConflict(s string, params ...interface{}) *Query func (*Query).Order(orders ...string) *Query func (*Query).OrderExpr(order string, params ...interface{}) *Query func (*Query).Relation(name string, apply ...func(*Query) (*Query, error)) *Query func (*Query).Returning(s string, params ...interface{}) *Query func (*Query).Set(set string, params ...interface{}) *Query func (*Query).Table(tables ...string) *Query func (*Query).TableExpr(expr string, params ...interface{}) *Query func (*Query).Union(other *Query) *Query func (*Query).UnionAll(other *Query) *Query func (*Query).Value(column string, value string, params ...interface{}) *Query func (*Query).Where(condition string, params ...interface{}) *Query func (*Query).WhereGroup(fn func(*Query) (*Query, error)) *Query func (*Query).WhereIn(where string, slice interface{}) *Query func (*Query).WhereInMulti(where string, values ...interface{}) *Query func (*Query).WhereInOr(where string, slice interface{}) *Query func (*Query).WhereNotGroup(fn func(*Query) (*Query, error)) *Query func (*Query).WhereOr(condition string, params ...interface{}) *Query func (*Query).WhereOrGroup(fn func(*Query) (*Query, error)) *Query func (*Query).WhereOrNotGroup(fn func(*Query) (*Query, error)) *Query func (*Query).WherePK() *Query func (*Query).With(name string, subq *Query) *Query func (*Query).WithDelete(name string, subq *Query) *Query func (*Query).WithInsert(name string, subq *Query) *Query func (*Query).WithUpdate(name string, subq *Query) *Query func (*Query).WrapWith(name string) *Query func QueryCommand.Query() *Query func (*SelectQuery).Query() *Query func (*UpdateQuery).Query() *Query func github.com/go-pg/pg/v10.Model(model ...interface{}) *pg.Query func github.com/go-pg/pg/v10.ModelContext(c context.Context, model ...interface{}) *pg.Query func github.com/go-pg/pg/v10.DBI.Model(model ...interface{}) *pg.Query func github.com/go-pg/pg/v10.DBI.ModelContext(c context.Context, model ...interface{}) *pg.Query func github.com/go-pg/pg/v10.(*Tx).Model(model ...interface{}) *pg.Query func github.com/go-pg/pg/v10.(*Tx).ModelContext(c context.Context, model ...interface{}) *pg.Query func github.com/go-pg/migrations/v8.DB.Model(model ...interface{}) *Query func NewCreateCompositeQuery(q *Query, opt *CreateCompositeOptions) *CreateCompositeQuery func NewCreateTableQuery(q *Query, opt *CreateTableOptions) *CreateTableQuery func NewDeleteQuery(q *Query) *DeleteQuery func NewDropCompositeQuery(q *Query, opt *DropCompositeOptions) *DropCompositeQuery func NewDropTableQuery(q *Query, opt *DropTableOptions) *DropTableQuery func NewInsertQuery(q *Query) *InsertQuery func NewSelectQuery(q *Query) *SelectQuery func NewUpdateQuery(q *Query, omitZero bool) *UpdateQuery func (*Query).Except(other *Query) *Query func (*Query).ExceptAll(other *Query) *Query func (*Query).Intersect(other *Query) *Query func (*Query).IntersectAll(other *Query) *Query func (*Query).Union(other *Query) *Query func (*Query).UnionAll(other *Query) *Query func (*Query).With(name string, subq *Query) *Query func (*Query).WithDelete(name string, subq *Query) *Query func (*Query).WithInsert(name string, subq *Query) *Query func (*Query).WithUpdate(name string, subq *Query) *Query
( QueryAppender) AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) *CreateCompositeQuery *CreateTableQuery *DeleteQuery *DropCompositeQuery *DropTableQuery *InsertQuery *Query QueryCommand (interface) *SafeQueryAppender *SelectQuery *UpdateQuery
( QueryCommand) AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) ( QueryCommand) AppendTemplate(b []byte) ([]byte, error) ( QueryCommand) Clone() QueryCommand ( QueryCommand) Operation() QueryOp ( QueryCommand) Query() *Query ( QueryCommand) String() string *CreateCompositeQuery *CreateTableQuery *DeleteQuery *DropCompositeQuery *DropTableQuery *InsertQuery *SelectQuery *UpdateQuery QueryCommand : QueryAppender QueryCommand : TemplateAppender QueryCommand : expvar.Var QueryCommand : fmt.Stringer func (*CreateCompositeQuery).Clone() QueryCommand func (*CreateTableQuery).Clone() QueryCommand func (*DeleteQuery).Clone() QueryCommand func (*DropCompositeQuery).Clone() QueryCommand func (*DropTableQuery).Clone() QueryCommand func (*InsertQuery).Clone() QueryCommand func QueryCommand.Clone() QueryCommand func (*SelectQuery).Clone() QueryCommand func (*UpdateQuery).Clone() QueryCommand
( QueryFormatter) FormatQuery(b []byte, query string, params ...interface{}) []byte *Formatter func DB.Formatter() QueryFormatter func github.com/go-pg/pg/v10.(*Tx).Formatter() QueryFormatter func (*CreateCompositeQuery).AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) func (*CreateTableQuery).AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) func (*DeleteQuery).AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) func (*DropCompositeQuery).AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) func (*DropTableQuery).AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) func (*InsertQuery).AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) func (*Query).AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) func QueryAppender.AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) func QueryCommand.AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) func (*SafeQueryAppender).AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) func (*SelectQuery).AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) func TableModel.AppendParam(QueryFormatter, []byte, string) ([]byte, bool) func (*UpdateQuery).AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error)
func (*CreateCompositeQuery).Operation() QueryOp func (*CreateTableQuery).Operation() QueryOp func (*DeleteQuery).Operation() QueryOp func (*DropCompositeQuery).Operation() QueryOp func (*DropTableQuery).Operation() QueryOp func (*InsertQuery).Operation() QueryOp func QueryCommand.Operation() QueryOp func (*SelectQuery).Operation() QueryOp func (*UpdateQuery).Operation() QueryOp const CreateCompositeOp const CreateTableOp const DeleteOp const DropCompositeOp const DropTableOp const InsertOp const SelectOp const UpdateOp
BaseFKs []*Field Field *Field JoinFKs []*Field JoinTable *Table M2MBaseFKs []string M2MJoinFKs []string M2MTableAlias types.Safe M2MTableName types.Safe Polymorphic *Field Type int (*Relation) String() string *Relation : expvar.Var *Relation : fmt.Stringer func TableModel.Relation() *Relation
Result summarizes an executed SQL command. ( Result) Model() Model RowsAffected returns the number of rows affected by SELECT, INSERT, UPDATE, or DELETE queries. It returns -1 if query can't possibly affect any rows, e.g. in case of CREATE or SHOW queries. RowsReturned returns the number of rows returned by the query. func DB.CopyFrom(r io.Reader, query interface{}, params ...interface{}) (Result, error) func DB.CopyTo(w io.Writer, query interface{}, params ...interface{}) (Result, error) func DB.Exec(query interface{}, params ...interface{}) (Result, error) func DB.ExecContext(c context.Context, query interface{}, params ...interface{}) (Result, error) func DB.ExecOne(query interface{}, params ...interface{}) (Result, error) func DB.ExecOneContext(c context.Context, query interface{}, params ...interface{}) (Result, error) func DB.Query(model, query interface{}, params ...interface{}) (Result, error) func DB.QueryContext(c context.Context, model, query interface{}, params ...interface{}) (Result, error) func DB.QueryOne(model, query interface{}, params ...interface{}) (Result, error) func DB.QueryOneContext(c context.Context, model, query interface{}, params ...interface{}) (Result, error) func (*Query).CopyFrom(r io.Reader, query interface{}, params ...interface{}) (Result, error) func (*Query).CopyTo(w io.Writer, query interface{}, params ...interface{}) (Result, error) func (*Query).Delete(values ...interface{}) (Result, error) func (*Query).Exec(query interface{}, params ...interface{}) (Result, error) func (*Query).ExecOne(query interface{}, params ...interface{}) (Result, error) func (*Query).ForceDelete(values ...interface{}) (Result, error) func (*Query).Insert(values ...interface{}) (Result, error) func (*Query).Query(model, query interface{}, params ...interface{}) (Result, error) func (*Query).QueryOne(model, query interface{}, params ...interface{}) (Result, error) func (*Query).Update(scan ...interface{}) (Result, error) func (*Query).UpdateNotZero(scan ...interface{}) (Result, error) func github.com/go-pg/pg/v10.DBI.CopyFrom(r io.Reader, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.CopyTo(w io.Writer, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.Exec(query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.ExecContext(c context.Context, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.ExecOne(query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.ExecOneContext(c context.Context, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.Query(model, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.QueryContext(c context.Context, model, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.QueryOne(model, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.DBI.QueryOneContext(c context.Context, model, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).Exec(params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).ExecContext(c context.Context, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).ExecOne(params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).ExecOneContext(c context.Context, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).Query(model interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).QueryContext(c context.Context, model interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).QueryOne(model interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Stmt).QueryOneContext(c context.Context, model interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).CopyFrom(r io.Reader, query interface{}, params ...interface{}) (res pg.Result, err error) func github.com/go-pg/pg/v10.(*Tx).CopyTo(w io.Writer, query interface{}, params ...interface{}) (res pg.Result, err error) func github.com/go-pg/pg/v10.(*Tx).Exec(query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).ExecContext(c context.Context, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).ExecOne(query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).ExecOneContext(c context.Context, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).Query(model interface{}, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).QueryContext(c context.Context, model interface{}, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).QueryOne(model interface{}, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/pg/v10.(*Tx).QueryOneContext(c context.Context, model interface{}, query interface{}, params ...interface{}) (pg.Result, error) func github.com/go-pg/migrations/v8.DB.CopyFrom(r io.Reader, query interface{}, params ...interface{}) (Result, error) func github.com/go-pg/migrations/v8.DB.CopyTo(w io.Writer, query interface{}, params ...interface{}) (Result, error) func github.com/go-pg/migrations/v8.DB.Exec(query interface{}, params ...interface{}) (Result, error) func github.com/go-pg/migrations/v8.DB.ExecOne(query interface{}, params ...interface{}) (Result, error) func github.com/go-pg/migrations/v8.DB.Query(coll, query interface{}, params ...interface{}) (Result, error) func github.com/go-pg/migrations/v8.DB.QueryOne(model, query interface{}, params ...interface{}) (Result, error)
(*SafeQueryAppender) AppendQuery(fmter QueryFormatter, b []byte) ([]byte, error) (*SafeQueryAppender) AppendValue(b []byte, quote int) ([]byte, error) (*SafeQueryAppender) Value() types.Safe *SafeQueryAppender : QueryAppender *SafeQueryAppender : github.com/go-pg/pg/v10/types.ValueAppender func SafeQuery(query string, params ...interface{}) *SafeQueryAppender func github.com/go-pg/pg/v10.SafeQuery(query string, params ...interface{}) *SafeQueryAppender
(*SelectQuery) AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) (*SelectQuery) AppendTemplate(b []byte) ([]byte, error) (*SelectQuery) Clone() QueryCommand (*SelectQuery) Operation() QueryOp (*SelectQuery) Query() *Query (*SelectQuery) String() string *SelectQuery : QueryAppender *SelectQuery : QueryCommand *SelectQuery : TemplateAppender *SelectQuery : expvar.Var *SelectQuery : fmt.Stringer func NewSelectQuery(q *Query) *SelectQuery
Table represents a SQL table created from Go struct. Alias types.Safe DataFields []*Field // PKs + DataFields FieldsMap map[string]*Field Methods map[string]*Method ModelName string PKs []*Field PartitionBy string Relations map[string]*Relation SQLName types.Safe SQLNameForSelects types.Safe SetSoftDeleteField func(fv reflect.Value) error SoftDeleteField *Field Tablespace types.Safe Type reflect.Type TypeName string Unique map[string][]*Field (*Table) AddField(field *Field) (*Table) AppendParam(b []byte, strct reflect.Value, name string) ([]byte, bool) (*Table) GetField(name string) (*Field, error) (*Table) HasField(name string) bool (*Table) RemoveField(field *Field) (*Table) String() string *Table : expvar.Var *Table : fmt.Stringer func GetTable(typ reflect.Type) *Table func TableModel.Table() *Table
AddColumnScanner adds the ColumnScanner to the model. ( TableModel) AddJoin(join) *join ( TableModel) AfterDelete(context.Context) error ( TableModel) AfterInsert(context.Context) error ( TableModel) AfterScan(context.Context) error ( TableModel) AfterSelect(context.Context) error ( TableModel) AfterUpdate(context.Context) error ( TableModel) AppendParam(QueryFormatter, []byte, string) ([]byte, bool) ( TableModel) BeforeDelete(context.Context) (context.Context, error) ( TableModel) BeforeInsert(context.Context) (context.Context, error) ( TableModel) BeforeUpdate(context.Context) (context.Context, error) ( TableModel) GetJoin(string) *join ( TableModel) GetJoins() []join ( TableModel) Index() []int Init is responsible to initialize/reset model state. It is called only once no matter how many rows were returned. ( TableModel) IsNil() bool ( TableModel) Join(string, func(*Query) (*Query, error)) *join ( TableModel) Kind() reflect.Kind ( TableModel) Mount(reflect.Value) NextColumnScanner returns a ColumnScanner that is used to scan columns from the current row. It is called once for every row. ( TableModel) ParentIndex() []int ( TableModel) Relation() *Relation ( TableModel) Root() reflect.Value ( TableModel) Table() *Table ( TableModel) Value() reflect.Value TableModel : AfterDeleteHook TableModel : AfterInsertHook TableModel : AfterScanHook TableModel : AfterSelectHook TableModel : AfterUpdateHook TableModel : BeforeDeleteHook TableModel : BeforeInsertHook TableModel : BeforeUpdateHook TableModel : HooklessModel TableModel : Model func (*Query).TableModel() TableModel func (*Formatter).WithTableModel(model TableModel) *Formatter
( TemplateAppender) AppendTemplate(b []byte) ([]byte, error) *CreateCompositeQuery *CreateTableQuery *DeleteQuery *DropCompositeQuery *DropTableQuery *InsertQuery QueryCommand (interface) *SelectQuery *UpdateQuery
(*UpdateQuery) AppendQuery(fmter QueryFormatter, b []byte) (_ []byte, err error) (*UpdateQuery) AppendTemplate(b []byte) ([]byte, error) (*UpdateQuery) Clone() QueryCommand (*UpdateQuery) Operation() QueryOp (*UpdateQuery) Query() *Query (*UpdateQuery) String() string *UpdateQuery : QueryAppender *UpdateQuery : QueryCommand *UpdateQuery : TemplateAppender *UpdateQuery : expvar.Var *UpdateQuery : fmt.Stringer func NewUpdateQuery(q *Query, omitZero bool) *UpdateQuery
Package-Level Functions (total 108, in which 17 are exported)
GetTable returns a Table for a struct type.
func NewModel(value interface{}) (Model, error)
func NewQuery(db DB, model ...interface{}) *Query
func NewQueryContext(ctx context.Context, db DB, model ...interface{}) *Query
RegisterTable registers a struct as SQL table. It is usually used to register intermediate table in many to many relationship.
nolint
nolint
SetTableNameInflector overrides the default func that pluralizes model name to get table name, e.g. my_article becomes my_articles.
Package-Level Constants (total 57, in which 19 are exported)
const CreateCompositeOp QueryOp = "CREATE COMPOSITE"
const CreateTableOp QueryOp = "CREATE TABLE"
const DeleteOp QueryOp = "DELETE"
const DropCompositeOp QueryOp = "DROP COMPOSITE"
const DropTableOp QueryOp = "DROP TABLE"
const InsertOp QueryOp = "INSERT"
const SelectOp QueryOp = "SELECT"
const UpdateOp QueryOp = "UPDATE"