Documentation ¶
Index ¶
- func DatabaseMigration(cfg *Config)
- func Init() (*sqlx.DB, error)
- type Adapter
- type Config
- type MySqlDB
- func (d *MySqlDB) Fetch(dst interface{}, query string, args ...interface{}) error
- func (d *MySqlDB) FetchRow(dst interface{}, query string, args ...interface{}) error
- func (d *MySqlDB) Ping(ctx context.Context) error
- func (p *MySqlDB) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (p *MySqlDB) QueryRow(query string, args ...interface{}) sql.Result
- func (p *MySqlDB) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (p *MySqlDB) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- type NewQueryBuilder
- func (qb *NewQueryBuilder) Create(table string, field string) *NewQueryBuilder
- func (qb *NewQueryBuilder) Delete(table string, field string, value interface{}) *NewQueryBuilder
- func (qb *NewQueryBuilder) From(table string) *NewQueryBuilder
- func (qb *NewQueryBuilder) JoinTable(table string, arg string) *NewQueryBuilder
- func (qb *NewQueryBuilder) Limit(numb int) *NewQueryBuilder
- func (qb *NewQueryBuilder) Offset(numb int) *NewQueryBuilder
- func (qb *NewQueryBuilder) OperatorEqual(field string, value interface{}) *NewQueryBuilder
- func (qb *NewQueryBuilder) OperatorIN(field string, value string) *NewQueryBuilder
- func (qb *NewQueryBuilder) OperatorLike(field string, value string) *NewQueryBuilder
- func (qb *NewQueryBuilder) OperatorORLike(field string, value string) *NewQueryBuilder
- func (qb *NewQueryBuilder) OrderBy(array []string) *NewQueryBuilder
- func (qb *NewQueryBuilder) Select(field string) *NewQueryBuilder
- func (qb *NewQueryBuilder) Update(table string, data map[string]interface{}) *NewQueryBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter interface { QueryRow(query string, args ...interface{}) sql.Result // QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row // QueryRows(ctx context.Context, query string, args ...interface{}) (rows *sql.Rows, err error) Fetch(dst interface{}, query string, args ...interface{}) error FetchRow(dst interface{}, query string, args ...interface{}) error // BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) // Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Ping(ctx context.Context) error Query(query string, args ...interface{}) (*sql.Rows, error) Queryx(query string, args ...interface{}) (*sqlx.Rows, error) QueryRowx(query string, args ...interface{}) *sqlx.Row UpdateQuery(table string, data map[string]interface{}) string }
type MySqlDB ¶
func (*MySqlDB) Fetch ¶
Fetch select multiple rows of database will cast data to struct passing by parameter
func (*MySqlDB) FetchRow ¶
FetchRow fetching one row database will cast data to struct passing by parameter
type NewQueryBuilder ¶
type NewQueryBuilder struct {
FullQuery string
}
func (*NewQueryBuilder) Create ¶
func (qb *NewQueryBuilder) Create(table string, field string) *NewQueryBuilder
table: users field: "name,created_at,updated_at" Create represents "insert into users (name,created_at,updated_at) values (?,?,?)"
func (*NewQueryBuilder) Delete ¶
func (qb *NewQueryBuilder) Delete(table string, field string, value interface{}) *NewQueryBuilder
func (*NewQueryBuilder) From ¶
func (qb *NewQueryBuilder) From(table string) *NewQueryBuilder
func (*NewQueryBuilder) JoinTable ¶
func (qb *NewQueryBuilder) JoinTable(table string, arg string) *NewQueryBuilder
arg: users.id,address_users.id onExpression: users.id = address_users.id JoinTable represents "Join table on users.id = address_users.id"
func (*NewQueryBuilder) Limit ¶
func (qb *NewQueryBuilder) Limit(numb int) *NewQueryBuilder
func (*NewQueryBuilder) Offset ¶
func (qb *NewQueryBuilder) Offset(numb int) *NewQueryBuilder
func (*NewQueryBuilder) OperatorEqual ¶
func (qb *NewQueryBuilder) OperatorEqual(field string, value interface{}) *NewQueryBuilder
field: email OperatorEqual represents "where email = value"
func (*NewQueryBuilder) OperatorIN ¶
func (qb *NewQueryBuilder) OperatorIN(field string, value string) *NewQueryBuilder
value: ari,budiman field: name OperatorORLike represents "where name in["ari","budiman"]"
func (*NewQueryBuilder) OperatorLike ¶
func (qb *NewQueryBuilder) OperatorLike(field string, value string) *NewQueryBuilder
field: email OperatorLike represents "where email LIKE %value%"
func (*NewQueryBuilder) OperatorORLike ¶
func (qb *NewQueryBuilder) OperatorORLike(field string, value string) *NewQueryBuilder
field: name,email OperatorORLike represents "where name LIKE "%value%" OR email LIKE "%value%""
func (*NewQueryBuilder) OrderBy ¶
func (qb *NewQueryBuilder) OrderBy(array []string) *NewQueryBuilder
func (*NewQueryBuilder) Select ¶
func (qb *NewQueryBuilder) Select(field string) *NewQueryBuilder
func (*NewQueryBuilder) Update ¶
func (qb *NewQueryBuilder) Update(table string, data map[string]interface{}) *NewQueryBuilder
UpdateQuery validate update query string