Documentation ¶
Index ¶
- Constants
- Variables
- type Binder
- type DB
- func (db *DB) Close() error
- func (db *DB) Driver() string
- func (db *DB) Lock(fn func(Execer, Binder) error) error
- func (db *DB) Migrate(dir string) (*migrate.Migrate, error)
- func (db *DB) MigrateUp(dir string) error
- func (db *DB) Update(fn func(Execer, Binder) error) (err error)
- func (db *DB) View(fn func(Queryer, Binder) error) error
- type Execer
- type Locker
- type Queryer
- type Scanner
Constants ¶
const ( Sqlite = "sqlite3" Mysql = "mysql" Postgres = "postgres" )
Database driver enums.
Variables ¶
var ErrOptimisticLock = errors.New("optimistic lock error")
ErrOptimisticLock is returned by if the struct being modified has a Version field and the value is not equal to the current value in the database
var ErrRecordNotFound = sql.ErrNoRows
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a pool of zero or more underlying connections to the drone database.
func (*DB) Lock ¶
Lock obtains a write lock to the database (sqlite only) and executes a function. Any error that is returned from the function is returned from the Lock() method.
func (*DB) Migrate ¶
https://github.com/golang-migrate/migrate dir is the ddl sql folder path
func (*DB) Update ¶
Update executes a function within the context of a read-write managed transaction. If no error is returned from the function then the transaction is committed. If an error is returned then the entire transaction is rolled back. Any error that is returned from the function or returned from the commit is returned from the Update() method.
type Execer ¶
Execer interface defines a set of methods for executing read and write commands against the database.
type Locker ¶
type Locker interface { Lock() Unlock() RLock() RUnlock() }
A Locker represents an object that can be locked and unlocked.