Documentation ¶
Overview ¶
Package dao provides a data access object for a database.
Index ¶
- Constants
- type DAO
- func (s *DAO) Begin() (*sqlx.Tx, error)
- func (s *DAO) Create(ctx context.Context, table tabler.Tabler, opts ...interface{}) (int64, error)
- func (s *DAO) Exec(ctx context.Context, query string, tx *sqlx.Tx, args ...interface{}) (sql.Result, error)
- func (s *DAO) GetCount(ctx context.Context, entity tabler.Tabler, condition params.Condition, ...) (uint64, error)
- func (s *DAO) List(ctx context.Context, dest interface{}, table tabler.Tabler, ...) error
- func (s *DAO) LockTable(ctx context.Context, tableName string, mode string, tx *sqlx.Tx) error
- func (s *DAO) Ping(ctx context.Context) error
- func (s *DAO) Update(ctx context.Context, entity tabler.Tabler, condition params.Condition, ...) error
- func (s *DAO) Upsert(ctx context.Context, entities []tabler.Tabler, opts ...interface{}) error
- type DAOFace
Constants ¶
View Source
const ( DriverMysql = "mysql" DriverPostgres = "postgres" DriverSqlite3 = "sqlite3" DriverRamsql = "ramsql" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DAO ¶
type DAO struct {
// contains filtered or unexported fields
}
DAO is a data access object.
func (*DAO) Create ¶
Create creates a new field in the database and returns the index of this field.
func (*DAO) Exec ¶
func (s *DAO) Exec(ctx context.Context, query string, tx *sqlx.Tx, args ...interface{}) (sql.Result, error)
Exec executes the specified query.
func (*DAO) GetCount ¶
func (s *DAO) GetCount(ctx context.Context, entity tabler.Tabler, condition params.Condition, opts ...interface{}) (uint64, error)
GetCount returns the number of rows that match a specified criterion.
func (*DAO) List ¶
func (s *DAO) List(ctx context.Context, dest interface{}, table tabler.Tabler, condition params.Condition, opts ...interface{}) error
List combines the values of a table column from multiple rows into a single comma-separated list of values.
type DAOFace ¶
type DAOFace interface { Begin() (*sqlx.Tx, error) Ping(ctx context.Context) error Create(ctx context.Context, entity tabler.Tabler, opts ...interface{}) (int64, error) Upsert(ctx context.Context, entities []tabler.Tabler, opts ...interface{}) error GetCount(ctx context.Context, entity tabler.Tabler, condition params.Condition, opts ...interface{}) (uint64, error) List(ctx context.Context, dest interface{}, table tabler.Tabler, condition params.Condition, opts ...interface{}) error Update(ctx context.Context, entity tabler.Tabler, condition params.Condition, operation string, opts ...interface{}) error Exec(ctx context.Context, query string, tx *sqlx.Tx, args ...interface{}) (sql.Result, error) LockTable(ctx context.Context, tableName string, mode string, tx *sqlx.Tx) error }
Click to show internal directories.
Click to hide internal directories.