Documentation ¶
Index ¶
- Variables
- func ErrNotFound(err error) bool
- type Association
- type Cache
- type Config
- type DB
- func (d *DB) AddError(err error) error
- func (d *DB) AddForeignKey(field string, dest string, onDelete string, onUpdate string) DBEngine
- func (d *DB) AddIndex(indexName string, columns ...string) DBEngine
- func (d *DB) AddUniqueIndex(indexName string, columns ...string) DBEngine
- func (d *DB) Assign(attrs ...interface{}) DBEngine
- func (d *DB) Association(column string) Association
- func (d *DB) Attrs(attrs ...interface{}) DBEngine
- func (d *DB) AutoMigrate(values ...interface{}) DBEngine
- func (d *DB) Begin() DBEngine
- func (d *DB) Cache() Cache
- func (d *DB) Close() error
- func (d *DB) Commit() DBEngine
- func (d *DB) Count(value interface{}) DBEngine
- func (d *DB) Create(value interface{}) DBEngine
- func (d *DB) CreateTable(values ...interface{}) DBEngine
- func (d *DB) DB() *sql.DB
- func (d *DB) Debug() DBEngine
- func (d *DB) Delete(value interface{}, where ...interface{}) DBEngine
- func (d *DB) DropColumn(column string) DBEngine
- func (d *DB) DropTable(values ...interface{}) DBEngine
- func (d *DB) DropTableIfExists(values ...interface{}) DBEngine
- func (d *DB) Error() error
- func (d *DB) Exec(sql string, values ...interface{}) DBEngine
- func (d *DB) Filter(query interface{}, arg interface{}) DBEngine
- func (d *DB) Find(out interface{}, where ...interface{}) DBEngine
- func (d *DB) First(out interface{}, where ...interface{}) DBEngine
- func (d *DB) FirstOrCreate(out interface{}, where ...interface{}) DBEngine
- func (d *DB) FirstOrInit(out interface{}, where ...interface{}) DBEngine
- func (d *DB) Get(name string) (interface{}, bool)
- func (d *DB) GetErrors() (errors []error)
- func (d *DB) Group(query string) DBEngine
- func (d *DB) HasTable(value interface{}) bool
- func (d *DB) Having(query string, values ...interface{}) DBEngine
- func (d *DB) InstantSet(name string, value interface{}) DBEngine
- func (d *DB) Joins(query string, args ...interface{}) DBEngine
- func (d *DB) Last(out interface{}, where ...interface{}) DBEngine
- func (d *DB) Limit(value int) DBEngine
- func (d *DB) LogMode(enable bool) DBEngine
- func (d *DB) Model(value interface{}) DBEngine
- func (d *DB) ModifyColumn(column string, typ string) DBEngine
- func (d *DB) New() DBEngine
- func (d *DB) NewRecord(value interface{}) bool
- func (d *DB) Not(query interface{}, args ...interface{}) DBEngine
- func (d *DB) Offset(value int) DBEngine
- func (d *DB) Omit(columns ...string) DBEngine
- func (d *DB) Or(query interface{}, args ...interface{}) DBEngine
- func (d *DB) Order(value string, reorder ...bool) DBEngine
- func (d *DB) Pluck(column string, value interface{}) DBEngine
- func (d *DB) Preload(column string, conditions ...interface{}) DBEngine
- func (d *DB) Raw(sql string, values ...interface{}) DBEngine
- func (d *DB) RecordNotFound() bool
- func (d *DB) Related(value interface{}, foreignKeys ...string) DBEngine
- func (d *DB) RemoveIndex(indexName string) DBEngine
- func (d *DB) Rollback() DBEngine
- func (d *DB) Row() *sql.Row
- func (d *DB) Rows() (*sql.Rows, error)
- func (d *DB) RowsAffected() int64
- func (d *DB) Save(value interface{}) DBEngine
- func (d *DB) Scan(dest interface{}) DBEngine
- func (d *DB) ScanRows(rows *sql.Rows, result interface{}) error
- func (d *DB) Select(query interface{}, args ...interface{}) DBEngine
- func (d *DB) Set(name string, value interface{}) DBEngine
- func (d *DB) SingularTable(enable bool)
- func (d *DB) Table(name string) DBEngine
- func (d *DB) Unscoped() DBEngine
- func (d *DB) Update(attrs ...interface{}) DBEngine
- func (d *DB) UpdateColumn(attrs ...interface{}) DBEngine
- func (d *DB) UpdateColumns(values interface{}) DBEngine
- func (d *DB) Updates(values interface{}, ignoreProtectedAttrs ...bool) DBEngine
- func (d *DB) Where(query interface{}, args ...interface{}) DBEngine
- type DBEngine
- type Option
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrRecordNotFound = gorm.ErrRecordNotFound
)
Functions ¶
func ErrNotFound ¶
Types ¶
type Association ¶
type Association interface { Find(value interface{}) Association Append(values ...interface{}) Association Replace(values ...interface{}) Association Delete(values ...interface{}) Association Count() int Error() error }
type Cache ¶
type Cache interface { Get(key interface{}) (value interface{}, ok bool) Add(key interface{}, value interface{}) Remove(key interface{}) }
type Config ¶
type DB ¶
type DB struct { DBCache Cache `inject:"db_cache"` // contains filtered or unexported fields }
func (*DB) AddForeignKey ¶
func (*DB) AddUniqueIndex ¶
func (*DB) Association ¶
func (d *DB) Association(column string) Association
func (*DB) AutoMigrate ¶
func (*DB) CreateTable ¶
func (*DB) DropColumn ¶
func (*DB) DropTableIfExists ¶
func (*DB) FirstOrCreate ¶
func (*DB) FirstOrInit ¶
func (*DB) InstantSet ¶
func (*DB) RecordNotFound ¶
func (*DB) RemoveIndex ¶
func (*DB) RowsAffected ¶
func (*DB) SingularTable ¶
func (*DB) UpdateColumn ¶
func (*DB) UpdateColumns ¶
type DBEngine ¶
type DBEngine interface { Close() error DB() *sql.DB New() DBEngine LogMode(enable bool) DBEngine SingularTable(enable bool) Where(query interface{}, args ...interface{}) DBEngine Filter(query interface{}, by interface{}) DBEngine Or(query interface{}, args ...interface{}) DBEngine Not(query interface{}, args ...interface{}) DBEngine Limit(value int) DBEngine Offset(value int) DBEngine Order(value string, reorder ...bool) DBEngine Select(query interface{}, args ...interface{}) DBEngine Omit(columns ...string) DBEngine Group(query string) DBEngine Having(query string, values ...interface{}) DBEngine Joins(query string, args ...interface{}) DBEngine Unscoped() DBEngine Attrs(attrs ...interface{}) DBEngine Assign(attrs ...interface{}) DBEngine First(out interface{}, where ...interface{}) DBEngine Last(out interface{}, where ...interface{}) DBEngine Find(out interface{}, where ...interface{}) DBEngine Scan(dest interface{}) DBEngine Row() *sql.Row Rows() (*sql.Rows, error) ScanRows(rows *sql.Rows, result interface{}) error Pluck(column string, value interface{}) DBEngine Count(value interface{}) DBEngine Related(value interface{}, foreignKeys ...string) DBEngine FirstOrInit(out interface{}, where ...interface{}) DBEngine FirstOrCreate(out interface{}, where ...interface{}) DBEngine Update(attrs ...interface{}) DBEngine Updates(values interface{}, ignoreProtectedAttrs ...bool) DBEngine UpdateColumn(attrs ...interface{}) DBEngine UpdateColumns(values interface{}) DBEngine Save(value interface{}) DBEngine Create(value interface{}) DBEngine Delete(value interface{}, where ...interface{}) DBEngine Raw(sql string, values ...interface{}) DBEngine Exec(sql string, values ...interface{}) DBEngine Model(value interface{}) DBEngine Table(name string) DBEngine Debug() DBEngine Begin() DBEngine Commit() DBEngine Rollback() DBEngine NewRecord(value interface{}) bool RecordNotFound() bool CreateTable(values ...interface{}) DBEngine DropTable(values ...interface{}) DBEngine DropTableIfExists(values ...interface{}) DBEngine HasTable(value interface{}) bool AutoMigrate(values ...interface{}) DBEngine ModifyColumn(column string, typ string) DBEngine DropColumn(column string) DBEngine AddIndex(indexName string, column ...string) DBEngine AddUniqueIndex(indexName string, column ...string) DBEngine RemoveIndex(indexName string) DBEngine AddForeignKey(field string, dest string, onDelete string, onUpdate string) DBEngine Preload(column string, conditions ...interface{}) DBEngine Set(name string, value interface{}) DBEngine InstantSet(name string, value interface{}) DBEngine Get(name string) (value interface{}, ok bool) Association(column string) Association AddError(err error) error GetErrors() (errors []error) // extra Error() error RowsAffected() int64 Cache() Cache }
DBEngine is an interface which DB implements. By then all test are well organized
func OpenInMemorySqlite ¶
Creates an sqlite memory db which will be database.DBEngine If WithCache is not provided, lru cache will be created as default.
Click to show internal directories.
Click to hide internal directories.