Versions in this module Expand all Collapse all v0 v0.0.6 Oct 9, 2024 v0.0.5 Sep 29, 2024 v0.0.4 Sep 27, 2024 v0.0.3 Sep 27, 2024 v0.0.2 Sep 24, 2024 Changes in this version + var ErrCheckConstraintViolated = errors.New("violates check constraint") + var ErrDryRunModeUnsupported = errors.New("dry run mode unsupported") + var ErrDuplicatedKey = errors.New("duplicated key not allowed") + var ErrEmptySlice = errors.New("empty slice found") + var ErrForeignKeyViolated = errors.New("violates foreign key constraint") + var ErrInvalidDB = errors.New("invalid db") + var ErrInvalidData = errors.New("unsupported data") + var ErrInvalidField = errors.New("invalid field") + var ErrInvalidTransaction = errors.New("invalid transaction") + var ErrInvalidValue = errors.New("invalid value, should be pointer to struct or slice") + var ErrInvalidValueOfLength = errors.New("invalid association values, length doesn't match") + var ErrMissingWhereClause = errors.New("WHERE conditions required") + var ErrModelAccessibleFieldsRequired = errors.New("model accessible fields required") + var ErrModelValueRequired = errors.New("model value required") + var ErrNotImplemented = errors.New("not implemented") + var ErrPreloadNotAllowed = errors.New("preload is not allowed when count is used") + var ErrPrimaryKeyRequired = errors.New("primary key required") + var ErrRecordNotFound = logger.ErrRecordNotFound + var ErrRegistered = errors.New("registered") + var ErrSubQueryRequired = errors.New("sub query required") + var ErrUnsupportedDriver = errors.New("unsupported driver") + var ErrUnsupportedRelation = errors.New("unsupported relations") + func Expr(expr string, args ...interface{}) clause.Expr + func Scan(rows Rows, db *DB, mode ScanMode) + type Association struct + DB *DB + Error error + Relationship *schema.Relationship + Unscope bool + func (association *Association) Append(values ...interface{}) error + func (association *Association) Clear() error + func (association *Association) Count() (count int64) + func (association *Association) Delete(values ...interface{}) error + func (association *Association) Find(out interface{}, conds ...interface{}) error + func (association *Association) Replace(values ...interface{}) error + func (association *Association) Unscoped() *Association + type ColumnType interface + AutoIncrement func() (isAutoIncrement bool, ok bool) + ColumnType func() (columnType string, ok bool) + Comment func() (value string, ok bool) + DatabaseTypeName func() string + DecimalSize func() (precision int64, scale int64, ok bool) + DefaultValue func() (value string, ok bool) + Length func() (length int64, ok bool) + Name func() string + Nullable func() (nullable bool, ok bool) + PrimaryKey func() (isPrimaryKey bool, ok bool) + ScanType func() reflect.Type + Unique func() (unique bool, ok bool) + type Config struct + AllowGlobalUpdate bool + ClauseBuilders map[string]clause.ClauseBuilder + ConnPool ConnPool + CreateBatchSize int + DisableAutomaticPing bool + DisableForeignKeyConstraintWhenMigrating bool + DisableNestedTransaction bool + DryRun bool + FullSaveAssociations bool + IgnoreRelationshipsWhenMigrating bool + Logger logger.Interface + NamingStrategy schema.Namer + NowFunc func() time.Time + Plugins map[string]Plugin + PrepareStmt bool + PropagateUnscoped bool + QueryFields bool + SkipDefaultTransaction bool + TranslateError bool + func (c *Config) AfterInitialize(db *DB) error + func (c *Config) Apply(config *Config) error + type ConnPool interface + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + PrepareContext func(ctx context.Context, query string) (*sql.Stmt, error) + QueryContext func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRowContext func(ctx context.Context, query string, args ...interface{}) *sql.Row + type ConnPoolBeginner interface + BeginTx func(ctx context.Context, opts *sql.TxOptions) (ConnPool, error) + type DB struct + Error error + RowsAffected int64 + Statement *Statement + func Open(dialector Dialector, opts ...Option) (db *DB, err error) + func (db *DB) AddError(err error) error + func (db *DB) Assign(attrs ...interface{}) (tx *DB) + func (db *DB) Association(column string) *Association + func (db *DB) Attrs(attrs ...interface{}) (tx *DB) + func (db *DB) AutoMigrate(dst ...interface{}) error + func (db *DB) Begin(opts ...*sql.TxOptions) *DB + func (db *DB) Callback() *callbacks + func (db *DB) Clauses(conds ...clause.Expression) (tx *DB) + func (db *DB) Commit() *DB + func (db *DB) Connection(fc func(tx *DB) error) (err error) + func (db *DB) Count(count *int64) (tx *DB) + func (db *DB) Create(value interface{}) (tx *DB) + func (db *DB) CreateInBatches(value interface{}, batchSize int) (tx *DB) + func (db *DB) DB() (*sql.DB, error) + func (db *DB) Debug() (tx *DB) + func (db *DB) Delete(value interface{}, conds ...interface{}) (tx *DB) + func (db *DB) Distinct(args ...interface{}) (tx *DB) + func (db *DB) Exec(sql string, values ...interface{}) (tx *DB) + func (db *DB) Find(dest interface{}, conds ...interface{}) (tx *DB) + func (db *DB) FindInBatches(dest interface{}, batchSize int, fc func(tx *DB, batch int) error) *DB + func (db *DB) First(dest interface{}, conds ...interface{}) (tx *DB) + func (db *DB) FirstOrCreate(dest interface{}, conds ...interface{}) (tx *DB) + func (db *DB) FirstOrInit(dest interface{}, conds ...interface{}) (tx *DB) + func (db *DB) Get(key string) (interface{}, bool) + func (db *DB) Group(name string) (tx *DB) + func (db *DB) Having(query interface{}, args ...interface{}) (tx *DB) + func (db *DB) InnerJoins(query string, args ...interface{}) (tx *DB) + func (db *DB) InstanceGet(key string) (interface{}, bool) + func (db *DB) InstanceSet(key string, value interface{}) *DB + func (db *DB) Joins(query string, args ...interface{}) (tx *DB) + func (db *DB) Last(dest interface{}, conds ...interface{}) (tx *DB) + func (db *DB) Limit(limit int) (tx *DB) + func (db *DB) MapColumns(m map[string]string) (tx *DB) + func (db *DB) Migrator() Migrator + func (db *DB) Model(value interface{}) (tx *DB) + func (db *DB) Not(query interface{}, args ...interface{}) (tx *DB) + func (db *DB) Offset(offset int) (tx *DB) + func (db *DB) Omit(columns ...string) (tx *DB) + func (db *DB) Or(query interface{}, args ...interface{}) (tx *DB) + func (db *DB) Order(value interface{}) (tx *DB) + func (db *DB) Pluck(column string, dest interface{}) (tx *DB) + func (db *DB) Preload(query string, args ...interface{}) (tx *DB) + func (db *DB) Raw(sql string, values ...interface{}) (tx *DB) + func (db *DB) Rollback() *DB + func (db *DB) RollbackTo(name string) *DB + func (db *DB) Row() *sql.Row + func (db *DB) Rows() (*sql.Rows, error) + func (db *DB) Save(value interface{}) (tx *DB) + func (db *DB) SavePoint(name string) *DB + func (db *DB) Scan(dest interface{}) (tx *DB) + func (db *DB) ScanRows(rows *sql.Rows, dest interface{}) error + func (db *DB) Scopes(funcs ...func(*DB) *DB) (tx *DB) + func (db *DB) Select(query interface{}, args ...interface{}) (tx *DB) + func (db *DB) Session(config *Session) *DB + func (db *DB) Set(key string, value interface{}) *DB + func (db *DB) SetupJoinTable(model interface{}, field string, joinTable interface{}) error + func (db *DB) Table(name string, args ...interface{}) (tx *DB) + func (db *DB) Take(dest interface{}, conds ...interface{}) (tx *DB) + func (db *DB) ToSQL(queryFn func(tx *DB) *DB) string + func (db *DB) Transaction(fc func(tx *DB) error, opts ...*sql.TxOptions) (err error) + func (db *DB) Unscoped() (tx *DB) + func (db *DB) Update(column string, value interface{}) (tx *DB) + func (db *DB) UpdateColumn(column string, value interface{}) (tx *DB) + func (db *DB) UpdateColumns(values interface{}) (tx *DB) + func (db *DB) Updates(values interface{}) (tx *DB) + func (db *DB) Use(plugin Plugin) error + func (db *DB) Where(query interface{}, args ...interface{}) (tx *DB) + func (db *DB) WithContext(ctx context.Context) *DB + type DeletedAt sql.NullTime + func (DeletedAt) DeleteClauses(f *schema.Field) []clause.Interface + func (DeletedAt) QueryClauses(f *schema.Field) []clause.Interface + func (DeletedAt) UpdateClauses(f *schema.Field) []clause.Interface + func (n *DeletedAt) Scan(value interface{}) error + func (n *DeletedAt) UnmarshalJSON(b []byte) error + func (n DeletedAt) MarshalJSON() ([]byte, error) + func (n DeletedAt) Value() (driver.Value, error) + type Dialector interface + BindVarTo func(writer clause.Writer, stmt *Statement, v interface{}) + DataTypeOf func(*schema.Field) string + DefaultValueOf func(*schema.Field) clause.Expression + Explain func(sql string, vars ...interface{}) string + Initialize func(*DB) error + Migrator func(db *DB) Migrator + Name func() string + QuoteTo func(clause.Writer, string) + type ErrorTranslator interface + Translate func(err error) error + type GetDBConnector interface + GetDBConn func() (*sql.DB, error) + type Index interface + Columns func() []string + Name func() string + Option func() string + PrimaryKey func() (isPrimaryKey bool, ok bool) + Table func() string + Unique func() (unique bool, ok bool) + type Migrator interface + AddColumn func(dst interface{}, field string) error + AlterColumn func(dst interface{}, field string) error + AutoMigrate func(dst ...interface{}) error + ColumnTypes func(dst interface{}) ([]ColumnType, error) + CreateConstraint func(dst interface{}, name string) error + CreateIndex func(dst interface{}, name string) error + CreateTable func(dst ...interface{}) error + CreateView func(name string, option ViewOption) error + CurrentDatabase func() string + DropColumn func(dst interface{}, field string) error + DropConstraint func(dst interface{}, name string) error + DropIndex func(dst interface{}, name string) error + DropTable func(dst ...interface{}) error + DropView func(name string) error + FullDataTypeOf func(*schema.Field) clause.Expr + GetIndexes func(dst interface{}) ([]Index, error) + GetTables func() (tableList []string, err error) + GetTypeAliases func(databaseTypeName string) []string + HasColumn func(dst interface{}, field string) bool + HasConstraint func(dst interface{}, name string) bool + HasIndex func(dst interface{}, name string) bool + HasTable func(dst interface{}) bool + MigrateColumn func(dst interface{}, field *schema.Field, columnType ColumnType) error + MigrateColumnUnique func(dst interface{}, field *schema.Field, columnType ColumnType) error + RenameColumn func(dst interface{}, oldName, field string) error + RenameIndex func(dst interface{}, oldName, newName string) error + RenameTable func(oldName, newName interface{}) error + TableType func(dst interface{}) (TableType, error) + type Model struct + CreatedAt time.Time + DeletedAt DeletedAt + ID uint + UpdatedAt time.Time + type Option interface + AfterInitialize func(*DB) error + Apply func(*Config) error + type ParamsFilter interface + ParamsFilter func(ctx context.Context, sql string, params ...interface{}) (string, []interface{}) + type Plugin interface + Initialize func(*DB) error + Name func() string + type PreparedStmtDB struct + Mux *sync.RWMutex + Stmts map[string]*Stmt + func NewPreparedStmtDB(connPool ConnPool) *PreparedStmtDB + func (db *PreparedStmtDB) BeginTx(ctx context.Context, opt *sql.TxOptions) (ConnPool, error) + func (db *PreparedStmtDB) Close() + func (db *PreparedStmtDB) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error) + func (db *PreparedStmtDB) GetDBConn() (*sql.DB, error) + func (db *PreparedStmtDB) Ping() error + func (db *PreparedStmtDB) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error) + func (db *PreparedStmtDB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row + func (sdb *PreparedStmtDB) Reset() + type PreparedStmtTX struct + PreparedStmtDB *PreparedStmtDB + func (db *PreparedStmtTX) GetDBConn() (*sql.DB, error) + func (tx *PreparedStmtTX) Commit() error + func (tx *PreparedStmtTX) ExecContext(ctx context.Context, query string, args ...interface{}) (result sql.Result, err error) + func (tx *PreparedStmtTX) Ping() error + func (tx *PreparedStmtTX) QueryContext(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error) + func (tx *PreparedStmtTX) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row + func (tx *PreparedStmtTX) Rollback() error + type Rows interface + Close func() error + ColumnTypes func() ([]*sql.ColumnType, error) + Columns func() ([]string, error) + Err func() error + Next func() bool + Scan func(dest ...interface{}) error + type SavePointerDialectorInterface interface + RollbackTo func(tx *DB, name string) error + SavePoint func(tx *DB, name string) error + type ScanMode uint8 + const ScanInitialized + const ScanOnConflictDoNothing + const ScanUpdate + type Session struct + AllowGlobalUpdate bool + Context context.Context + CreateBatchSize int + DisableNestedTransaction bool + DryRun bool + FullSaveAssociations bool + Initialized bool + Logger logger.Interface + NewDB bool + NowFunc func() time.Time + PrepareStmt bool + PropagateUnscoped bool + QueryFields bool + SkipDefaultTransaction bool + SkipHooks bool + type SoftDeleteDeleteClause struct + Field *schema.Field + ZeroValue sql.NullString + func (sd SoftDeleteDeleteClause) Build(clause.Builder) + func (sd SoftDeleteDeleteClause) MergeClause(*clause.Clause) + func (sd SoftDeleteDeleteClause) ModifyStatement(stmt *Statement) + func (sd SoftDeleteDeleteClause) Name() string + type SoftDeleteQueryClause struct + Field *schema.Field + ZeroValue sql.NullString + func (sd SoftDeleteQueryClause) Build(clause.Builder) + func (sd SoftDeleteQueryClause) MergeClause(*clause.Clause) + func (sd SoftDeleteQueryClause) ModifyStatement(stmt *Statement) + func (sd SoftDeleteQueryClause) Name() string + type SoftDeleteUpdateClause struct + Field *schema.Field + ZeroValue sql.NullString + func (sd SoftDeleteUpdateClause) Build(clause.Builder) + func (sd SoftDeleteUpdateClause) MergeClause(*clause.Clause) + func (sd SoftDeleteUpdateClause) ModifyStatement(stmt *Statement) + func (sd SoftDeleteUpdateClause) Name() string + type Statement struct + BuildClauses []string + Clauses map[string]clause.Clause + ColumnMapping map[string]string + ConnPool ConnPool + Context context.Context + CurDestIndex int + Dest interface{} + Distinct bool + Joins []join + Model interface{} + Omits []string + Preloads map[string][]interface{} + RaiseErrorOnNotFound bool + ReflectValue reflect.Value + SQL strings.Builder + Schema *schema.Schema + Selects []string + Settings sync.Map + SkipHooks bool + Table string + TableExpr *clause.Expr + Unscoped bool + Vars []interface{} + func (stmt *Statement) AddClause(v clause.Interface) + func (stmt *Statement) AddClauseIfNotExists(v clause.Interface) + func (stmt *Statement) AddVar(writer clause.Writer, vars ...interface{}) + func (stmt *Statement) Build(clauses ...string) + func (stmt *Statement) BuildCondition(query interface{}, args ...interface{}) []clause.Expression + func (stmt *Statement) Changed(fields ...string) bool + func (stmt *Statement) Parse(value interface{}) (err error) + func (stmt *Statement) ParseWithSpecialTableName(value interface{}, specialTableName string) (err error) + func (stmt *Statement) Quote(field interface{}) string + func (stmt *Statement) QuoteTo(writer clause.Writer, field interface{}) + func (stmt *Statement) SelectAndOmitColumns(requireCreate, requireUpdate bool) (map[string]bool, bool) + func (stmt *Statement) SetColumn(name string, value interface{}, fromCallbacks ...bool) + func (stmt *Statement) WriteByte(c byte) error + func (stmt *Statement) WriteQuoted(value interface{}) + func (stmt *Statement) WriteString(str string) (int, error) + type StatementModifier interface + ModifyStatement func(*Statement) + type Stmt struct + Transaction bool + type TableType interface + Comment func() (comment string, ok bool) + Name func() string + Schema func() string + Type func() string + type Tx interface + StmtContext func(ctx context.Context, stmt *sql.Stmt) *sql.Stmt + type TxBeginner interface + BeginTx func(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) + type TxCommitter interface + Commit func() error + Rollback func() error + type Valuer interface + GormValue func(context.Context, *DB) clause.Expr + type ViewOption struct + CheckOption string + Query *DB + Replace bool