Documentation ¶
Index ¶
- Constants
- func ConnectString(cfg Config) string
- func FromContext(ctx context.Context) (*gorm.DB, bool)
- func IsDuplicateEntry(err error) bool
- func IsDuplicateErr(err error) bool
- func IsDuplicateKey(err error) bool
- func Open(connectString string) (*gorm.DB, error)
- func OpenNative(connectString string) (*sql.DB, error)
- type Accessor
- type Config
- type Mock
- func (m *Mock) Begin(db *gorm.DB) *gorm.DB
- func (m *Mock) Close(db *gorm.DB) error
- func (m *Mock) Commit(db *gorm.DB) *gorm.DB
- func (m *Mock) Open() (*gorm.DB, error)
- func (m *Mock) ReadOnly(ctx context.Context, callback func(ctx context.Context, db *gorm.DB) error) error
- func (m *Mock) Rollback(db *gorm.DB) *gorm.DB
- func (m *Mock) Tx(ctx context.Context, callback func(ctx context.Context, db *gorm.DB) error) error
- type OpenFunc
- func (fn OpenFunc) Begin(db *gorm.DB) *gorm.DB
- func (fn OpenFunc) Close(db *gorm.DB) error
- func (fn OpenFunc) Commit(db *gorm.DB) *gorm.DB
- func (fn OpenFunc) Open() (*gorm.DB, error)
- func (fn OpenFunc) ReadOnly(ctx context.Context, callback func(ctx context.Context, db *gorm.DB) error) error
- func (fn OpenFunc) Rollback(db *gorm.DB) *gorm.DB
- func (fn OpenFunc) Tx(ctx context.Context, callback func(ctx context.Context, db *gorm.DB) error) error
Constants ¶
View Source
const ( MySQLDuplicateKeyNum = 1061 MySQLDuplicateEntryNum = 1062 )
View Source
const (
Key = "_db"
)
Variables ¶
This section is empty.
Functions ¶
func ConnectString ¶
func FromContext ¶
FromContext retrieves a db instance from a context
func IsDuplicateEntry ¶
func IsDuplicateErr ¶
func IsDuplicateKey ¶
Types ¶
type Accessor ¶
type Accessor interface { Open() (*gorm.DB, error) Close(*gorm.DB) error Begin(*gorm.DB) *gorm.DB Commit(*gorm.DB) *gorm.DB Rollback(*gorm.DB) *gorm.DB Tx(ctx context.Context, callback func(ctx context.Context, db *gorm.DB) error) error ReadOnly(ctx context.Context, callback func(ctx context.Context, db *gorm.DB) error) error }
type Mock ¶
type Mock struct { DB *gorm.DB OpenCount int CloseCount int BeginCount int CommitCount int RollbackCount int TxCount int ReadOnlyCount int }
Click to show internal directories.
Click to hide internal directories.