Skip to content

Commit

Permalink
Add DB.Ping
Browse files Browse the repository at this point in the history
  • Loading branch information
gernest committed Sep 22, 2017
1 parent 0ce4dab commit d2fa3d1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ngorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,14 @@ func (db *DB) ModifyColumn(column string, typ string) (sql.Result, error) {
)
}

// Ping checks if you can connect to the database
func (db *DB) Ping() error {
if dr, ok := db.db.SQLCommon.(*sql.DB); ok {
return dr.Ping()
}
return errors.New("ngorm: ping not supported")
}

// Preload preload associations with given conditions
// db.Preload("Orders", "state NOT IN (?)", "cancelled").Find(&users)
func (db *DB) Preload(column string, conditions ...interface{}) *DB {
Expand Down

0 comments on commit d2fa3d1

Please sign in to comment.