Skip to content

Commit

Permalink
Adding access to underlying gorm DB
Browse files Browse the repository at this point in the history
  • Loading branch information
jloom6 committed Apr 14, 2019
1 parent 06b8bea commit 8f942b6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 25 deletions.
40 changes: 16 additions & 24 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Interface interface {
Value() interface{}
Error() error
RowsAffected() int64
// Allow users access to the underlying gorm DB
GetGormDB() *gorm.DB
// Wrap the functions
New() Interface
Close() error
Expand Down
7 changes: 6 additions & 1 deletion jorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (db *DB) HasTable(value interface{}) bool {

// AutoMigrate run auto migration for given models, will only add missing fields, won't delete/change current data
func (db *DB) AutoMigrate(values ...interface{}) Interface {
return &DB{db: db.db.AutoMigrate(values)}
return &DB{db: db.db.AutoMigrate(values...)}
}

// ModifyColumn modify column to type
Expand Down Expand Up @@ -451,3 +451,8 @@ func (db *DB) AddError(err error) error {
func (db *DB) GetErrors() []error {
return db.db.GetErrors()
}

// GetGormDB returns the underlying gorm DB
func (db *DB) GetGormDB() *gorm.DB {
return db.db
}
28 changes: 28 additions & 0 deletions mocks/jorm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8f942b6

Please sign in to comment.