gorm/interface.go

25 lines
582 B
Go
Raw Normal View History

2013-11-11 09:16:08 +04:00
package gorm
import (
"context"
"database/sql"
)
2013-11-11 09:16:08 +04:00
// SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB.
type SQLCommon interface {
2013-11-11 09:16:08 +04:00
Exec(query string, args ...interface{}) (sql.Result, error)
Prepare(query string) (*sql.Stmt, error)
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
}
2013-11-16 04:15:21 +04:00
type sqlDb interface {
2013-11-11 09:16:08 +04:00
Begin() (*sql.Tx, error)
BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
2013-11-11 09:16:08 +04:00
}
2013-11-16 04:15:21 +04:00
type sqlTx interface {
2013-11-11 09:16:08 +04:00
Commit() error
Rollback() error
}