Versions in this module Expand all Collapse all v1 v1.9.1 Feb 27, 2018 Changes in this version + var DefaultCallback = &Callback + var DefaultTableNameHandler = func(db *DB, defaultTableName string) string + var ErrCantStartTransaction = errors.New("can't start transaction") + var ErrInvalidSQL = errors.New("invalid SQL") + var ErrInvalidTransaction = errors.New("no valid transaction") + var ErrRecordNotFound = errors.New("record not found") + var ErrUnaddressable = errors.New("using unaddressable value") + var LogFormatter = func(values ...interface{}) (messages []interface{}) + var NowFunc = func() time.Time + var ParseFieldStructForDialect = func(field *StructField, dialect Dialect) (fieldValue reflect.Value, sqlType string, size int, additionalType string) + func Expr(expression string, args ...interface{}) *expr + func IsByteArrayOrSlice(value reflect.Value) bool + func IsRecordNotFoundError(err error) bool + func RegisterDialect(name string, dialect Dialect) + func ToDBName(name string) string + type Association struct + Error error + func (association *Association) Append(values ...interface{}) *Association + func (association *Association) Clear() *Association + func (association *Association) Count() int + func (association *Association) Delete(values ...interface{}) *Association + func (association *Association) Find(value interface{}) *Association + func (association *Association) Replace(values ...interface{}) *Association + type Callback struct + func (c *Callback) Create() *CallbackProcessor + func (c *Callback) Delete() *CallbackProcessor + func (c *Callback) Query() *CallbackProcessor + func (c *Callback) RowQuery() *CallbackProcessor + func (c *Callback) Update() *CallbackProcessor + type CallbackProcessor struct + func (cp *CallbackProcessor) After(callbackName string) *CallbackProcessor + func (cp *CallbackProcessor) Before(callbackName string) *CallbackProcessor + func (cp *CallbackProcessor) Get(callbackName string) (callback func(scope *Scope)) + func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *Scope)) + func (cp *CallbackProcessor) Remove(callbackName string) + func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *Scope)) + type DB struct + Error error + RowsAffected int64 + Value interface{} + func Open(dialect string, args ...interface{}) (db *DB, err error) + func (s *DB) AddError(err error) error + func (s *DB) AddForeignKey(field string, dest string, onDelete string, onUpdate string) *DB + func (s *DB) AddIndex(indexName string, columns ...string) *DB + func (s *DB) AddUniqueIndex(indexName string, columns ...string) *DB + func (s *DB) Assign(attrs ...interface{}) *DB + func (s *DB) Association(column string) *Association + func (s *DB) Attrs(attrs ...interface{}) *DB + func (s *DB) AutoMigrate(values ...interface{}) *DB + func (s *DB) Begin() *DB + func (s *DB) BlockGlobalUpdate(enable bool) *DB + func (s *DB) Callback() *Callback + func (s *DB) Close() error + func (s *DB) Commit() *DB + func (s *DB) CommonDB() SQLCommon + func (s *DB) Count(value interface{}) *DB + func (s *DB) Create(value interface{}) *DB + func (s *DB) CreateTable(models ...interface{}) *DB + func (s *DB) DB() *sql.DB + func (s *DB) Debug() *DB + func (s *DB) Delete(value interface{}, where ...interface{}) *DB + func (s *DB) Dialect() Dialect + func (s *DB) DropColumn(column string) *DB + func (s *DB) DropTable(values ...interface{}) *DB + func (s *DB) DropTableIfExists(values ...interface{}) *DB + func (s *DB) Exec(sql string, values ...interface{}) *DB + func (s *DB) Find(out interface{}, where ...interface{}) *DB + func (s *DB) First(out interface{}, where ...interface{}) *DB + func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB + func (s *DB) FirstOrInit(out interface{}, where ...interface{}) *DB + func (s *DB) Get(name string) (value interface{}, ok bool) + func (s *DB) GetErrors() []error + func (s *DB) Group(query string) *DB + func (s *DB) HasBlockGlobalUpdate() bool + func (s *DB) HasTable(value interface{}) bool + func (s *DB) Having(query interface{}, values ...interface{}) *DB + func (s *DB) InstantSet(name string, value interface{}) *DB + func (s *DB) Joins(query string, args ...interface{}) *DB + func (s *DB) Last(out interface{}, where ...interface{}) *DB + func (s *DB) Limit(limit interface{}) *DB + func (s *DB) LogMode(enable bool) *DB + func (s *DB) Model(value interface{}) *DB + func (s *DB) ModifyColumn(column string, typ string) *DB + func (s *DB) New() *DB + func (s *DB) NewRecord(value interface{}) bool + func (s *DB) NewScope(value interface{}) *Scope + func (s *DB) Not(query interface{}, args ...interface{}) *DB + func (s *DB) Offset(offset interface{}) *DB + func (s *DB) Omit(columns ...string) *DB + func (s *DB) Or(query interface{}, args ...interface{}) *DB + func (s *DB) Order(value interface{}, reorder ...bool) *DB + func (s *DB) Pluck(column string, value interface{}) *DB + func (s *DB) Preload(column string, conditions ...interface{}) *DB + func (s *DB) QueryExpr() *expr + func (s *DB) Raw(sql string, values ...interface{}) *DB + func (s *DB) RecordNotFound() bool + func (s *DB) Related(value interface{}, foreignKeys ...string) *DB + func (s *DB) RemoveForeignKey(field string, dest string) *DB + func (s *DB) RemoveIndex(indexName string) *DB + func (s *DB) Rollback() *DB + func (s *DB) Row() *sql.Row + func (s *DB) Rows() (*sql.Rows, error) + func (s *DB) Save(value interface{}) *DB + func (s *DB) Scan(dest interface{}) *DB + func (s *DB) ScanRows(rows *sql.Rows, result interface{}) error + func (s *DB) Scopes(funcs ...func(*DB) *DB) *DB + func (s *DB) Select(query interface{}, args ...interface{}) *DB + func (s *DB) Set(name string, value interface{}) *DB + func (s *DB) SetJoinTableHandler(source interface{}, column string, handler JoinTableHandlerInterface) + func (s *DB) SetLogger(log logger) + func (s *DB) SingularTable(enable bool) + func (s *DB) SubQuery() *expr + func (s *DB) Table(name string) *DB + func (s *DB) Take(out interface{}, where ...interface{}) *DB + func (s *DB) Unscoped() *DB + func (s *DB) Update(attrs ...interface{}) *DB + func (s *DB) UpdateColumn(attrs ...interface{}) *DB + func (s *DB) UpdateColumns(values interface{}) *DB + func (s *DB) Updates(values interface{}, ignoreProtectedAttrs ...bool) *DB + func (s *DB) Where(query interface{}, args ...interface{}) *DB + type DefaultForeignKeyNamer struct + func (DefaultForeignKeyNamer) BuildKeyName(kind, tableName string, fields ...string) string + type Dialect interface + BindVar func(i int) string + BuildKeyName func(kind, tableName string, fields ...string) string + CurrentDatabase func() string + DataTypeOf func(field *StructField) string + DefaultValueStr func() string + GetName func() string + HasColumn func(tableName string, columnName string) bool + HasForeignKey func(tableName string, foreignKeyName string) bool + HasIndex func(tableName string, indexName string) bool + HasTable func(tableName string) bool + LastInsertIDReturningSuffix func(tableName, columnName string) string + LimitAndOffsetSQL func(limit, offset interface{}) string + ModifyColumn func(tableName string, columnName string, typ string) error + Quote func(key string) string + RemoveIndex func(tableName string, indexName string) error + SelectFromDummyTable func() string + SetDB func(db SQLCommon) + type Errors []error + func (errs Errors) Add(newErrors ...error) Errors + func (errs Errors) Error() string + func (errs Errors) GetErrors() []error + type Field struct + Field reflect.Value + IsBlank bool + func (field *Field) Set(value interface{}) (err error) + type JoinTableForeignKey struct + AssociationDBName string + DBName string + type JoinTableHandler struct + Destination JoinTableSource + Source JoinTableSource + TableName string + func (s *JoinTableHandler) DestinationForeignKeys() []JoinTableForeignKey + func (s *JoinTableHandler) Setup(relationship *Relationship, tableName string, source reflect.Type, ...) + func (s *JoinTableHandler) SourceForeignKeys() []JoinTableForeignKey + func (s JoinTableHandler) Add(handler JoinTableHandlerInterface, db *DB, source interface{}, ...) error + func (s JoinTableHandler) Delete(handler JoinTableHandlerInterface, db *DB, sources ...interface{}) error + func (s JoinTableHandler) JoinWith(handler JoinTableHandlerInterface, db *DB, source interface{}) *DB + func (s JoinTableHandler) Table(db *DB) string + type JoinTableHandlerInterface interface + Add func(handler JoinTableHandlerInterface, db *DB, source interface{}, ...) error + Delete func(handler JoinTableHandlerInterface, db *DB, sources ...interface{}) error + DestinationForeignKeys func() []JoinTableForeignKey + JoinWith func(handler JoinTableHandlerInterface, db *DB, source interface{}) *DB + Setup func(relationship *Relationship, tableName string, source reflect.Type, ...) + SourceForeignKeys func() []JoinTableForeignKey + Table func(db *DB) string + type JoinTableSource struct + ForeignKeys []JoinTableForeignKey + ModelType reflect.Type + type LogWriter interface + Println func(v ...interface{}) + type Logger struct + func (logger Logger) Print(values ...interface{}) + type Model struct + CreatedAt time.Time + DeletedAt *time.Time + ID uint + UpdatedAt time.Time + type ModelStruct struct + ModelType reflect.Type + PrimaryFields []*StructField + StructFields []*StructField + func (s *ModelStruct) TableName(db *DB) string + type Relationship struct + AssociationForeignDBNames []string + AssociationForeignFieldNames []string + ForeignDBNames []string + ForeignFieldNames []string + JoinTableHandler JoinTableHandlerInterface + Kind string + PolymorphicDBName string + PolymorphicType string + PolymorphicValue string + type RowQueryResult struct + Row *sql.Row + type RowsQueryResult struct + Error error + Rows *sql.Rows + type SQLCommon interface + Exec func(query string, args ...interface{}) (sql.Result, error) + Prepare func(query string) (*sql.Stmt, error) + Query func(query string, args ...interface{}) (*sql.Rows, error) + QueryRow func(query string, args ...interface{}) *sql.Row + type Scope struct + SQL string + SQLVars []interface{} + Search *search + Value interface{} + func (scope *Scope) AddToVars(value interface{}) string + func (scope *Scope) Begin() *Scope + func (scope *Scope) CallMethod(methodName string) + func (scope *Scope) CombinedConditionSql() string + func (scope *Scope) CommitOrRollback() *Scope + func (scope *Scope) DB() *DB + func (scope *Scope) Dialect() Dialect + func (scope *Scope) Err(err error) error + func (scope *Scope) Exec() *Scope + func (scope *Scope) FieldByName(name string) (field *Field, ok bool) + func (scope *Scope) Fields() []*Field + func (scope *Scope) Get(name string) (interface{}, bool) + func (scope *Scope) GetModelStruct() *ModelStruct + func (scope *Scope) GetStructFields() (fields []*StructField) + func (scope *Scope) HasColumn(column string) bool + func (scope *Scope) HasError() bool + func (scope *Scope) IndirectValue() reflect.Value + func (scope *Scope) InstanceGet(name string) (interface{}, bool) + func (scope *Scope) InstanceID() string + func (scope *Scope) InstanceSet(name string, value interface{}) *Scope + func (scope *Scope) Log(v ...interface{}) + func (scope *Scope) New(value interface{}) *Scope + func (scope *Scope) NewDB() *DB + func (scope *Scope) OmitAttrs() []string + func (scope *Scope) PrimaryField() *Field + func (scope *Scope) PrimaryFields() (fields []*Field) + func (scope *Scope) PrimaryKey() string + func (scope *Scope) PrimaryKeyValue() interface{} + func (scope *Scope) PrimaryKeyZero() bool + func (scope *Scope) Quote(str string) string + func (scope *Scope) QuotedTableName() (name string) + func (scope *Scope) Raw(sql string) *Scope + func (scope *Scope) SQLDB() SQLCommon + func (scope *Scope) SelectAttrs() []string + func (scope *Scope) Set(name string, value interface{}) *Scope + func (scope *Scope) SetColumn(column interface{}, value interface{}) error + func (scope *Scope) SkipLeft() + func (scope *Scope) TableName() string + type StructField struct + DBName string + HasDefaultValue bool + IsForeignKey bool + IsIgnored bool + IsNormal bool + IsPrimaryKey bool + IsScanner bool + Name string + Names []string + Relationship *Relationship + Struct reflect.StructField + Tag reflect.StructTag + TagSettings map[string]string