mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
reorganization of _examples and add some new examples such as iris+groupcache+mysql+docker
Former-commit-id: ed635ee95de7160cde11eaabc0c1dcb0e460a620
This commit is contained in:
40
_examples/database/mysql/sql/sql.go
Normal file
40
_examples/database/mysql/sql/sql.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package sql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
// Database is an interface which a database(sql) should implement.
|
||||
type Database interface {
|
||||
Get(ctx context.Context, dest interface{}, q string, args ...interface{}) error
|
||||
Select(ctx context.Context, dest interface{}, q string, args ...interface{}) error
|
||||
Exec(ctx context.Context, q string, args ...interface{}) (sql.Result, error)
|
||||
}
|
||||
|
||||
// Record should represent a database record.
|
||||
// It holds the table name and the primary key.
|
||||
// Entities should implement that
|
||||
// in order to use the BaseService's methods.
|
||||
type Record interface {
|
||||
TableName() string // the table name which record belongs to.
|
||||
PrimaryKey() string // the primary key of the record.
|
||||
}
|
||||
|
||||
// Sorted should represent a set of database records
|
||||
// that should be rendered with order.
|
||||
//
|
||||
// It does NOT support the form of
|
||||
// column1 ASC,
|
||||
// column2 DESC
|
||||
// The OrderBy method should return text in form of:
|
||||
// column1
|
||||
// or column1, column2
|
||||
type Sorted interface {
|
||||
SortBy() string // column names separated by comma.
|
||||
}
|
||||
|
||||
// Scannable for go structs to bind their fields.
|
||||
type Scannable interface {
|
||||
Scan(*sql.Rows) error
|
||||
}
|
||||
Reference in New Issue
Block a user