// go第三方库文档 数据库操作gorm
// https://pkg.go.dev/github.com/jinzhu/gorm
func AddNamingStrategy(ns *NamingStrategy)
func IsByteArrayOrSlice(value reflect.Value) bool
func IsRecordNotFoundError(err error) bool
func RegisterDialect(name string, dialect Dialect)
func ToColumnName(name string) string
func ToDBName(name string) string
func ToTableName(name string) string
type Association
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
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
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
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) BeginTx(ctx context.Context, opts *sql.TxOptions) *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) Preloads(out interface{}) *DB
func (s *DB) QueryExpr() *SqlExpr
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) RollbackUnlessCommitted() *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) SetNowFuncOverride(nowFuncOverride func() time.Time) *DB
func (s *DB) SingularTable(enable bool)
func (s *DB) SubQuery() *SqlExpr
func (s *DB) Table(name string) *DB
func (s *DB) Take(out interface{}, where ...interface{}) *DB
func (s *DB) Transaction(fc func(tx *DB) error) (err error)
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
func (DefaultForeignKeyNamer) BuildKeyName(kind, tableName string, fields ...string) string
type Dialect
func GetDialect(name string) (dialect Dialect, ok bool)
type Errors
func (errs Errors) Add(newErrors ...error) Errors
func (errs Errors) Error() string
func (errs Errors) GetErrors() []error
type Field
func (field *Field) Set(value interface{}) (err error)
type JoinTableForeignKey
type JoinTableHandler
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) DestinationForeignKeys() []JoinTableForeignKey
func (s JoinTableHandler) JoinWith(handler JoinTableHandlerInterface, db *DB, source interface{}) *DB
func (s *JoinTableHandler) Setup(relationship *Relationship, tableName string, source reflect.Type, ...)
func (s *JoinTableHandler) SourceForeignKeys() []JoinTableForeignKey
func (s JoinTableHandler) Table(db *DB) string
type JoinTableHandlerInterface
type JoinTableSource
type LogWriter
type Logger
func (logger Logger) Print(values ...interface{})
type Model
type ModelStruct
func (s *ModelStruct) TableName(db *DB) string
type Namer
type NamingStrategy
func (ns *NamingStrategy) ColumnName(name string) string
func (ns *NamingStrategy) DBName(name string) string
func (ns *NamingStrategy) TableName(name string) string
type Relationship
type RowQueryResult
type RowsQueryResult
type SQLCommon
type Scope
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 *Sco
go第三方库文档 数据库操作gorm
最新推荐文章于 2025-10-09 11:36:42 发布
GORM 是一个用于 Go 语言的 ORM 库,提供了丰富的数据库操作功能,如创建、查询、更新和删除记录。它支持多种数据库方言,如 MySQL、PostgreSQL、SQLite 和 SQL Server。GORM 提供了回调系统、事务处理、预加载关联等功能,简化了数据库交互。本文深入介绍了 GORM 的主要方法,如 `AddError`、`AutoMigrate`、`Create`、`Delete`、`Find`、`Preload` 和 `Update`,以及如何处理关联、事务和错误。此外,还展示了如何自定义回调、命名策略和日志记录。

最低0.47元/天 解锁文章
1021

被折叠的 条评论
为什么被折叠?



