Documentation
¶
Overview ¶
Package sql is general sql adapter that wraps database/sql.
Index ¶
- Variables
- func ExtractString(s, left, right string) string
- type Adapter
- func (adapter *Adapter) Aggregate(ctx context.Context, query rel.Query, mode string, field string) (int, error)
- func (adapter *Adapter) Begin(ctx context.Context) (rel.Adapter, error)
- func (adapter *Adapter) Close() error
- func (adapter *Adapter) Commit(ctx context.Context) error
- func (adapter *Adapter) Delete(ctx context.Context, query rel.Query) (int, error)
- func (adapter *Adapter) Exec(ctx context.Context, statement string, args []interface{}) (int64, int64, error)
- func (adapter *Adapter) Insert(ctx context.Context, query rel.Query, mutates map[string]rel.Mutate) (interface{}, error)
- func (adapter *Adapter) InsertAll(ctx context.Context, query rel.Query, fields []string, ...) ([]interface{}, error)
- func (adapter *Adapter) Instrument(ctx context.Context, op string, message string) func(err error)
- func (adapter *Adapter) Instrumentation(instrumenter rel.Instrumenter)
- func (adapter *Adapter) Ping(ctx context.Context) error
- func (adapter *Adapter) Query(ctx context.Context, query rel.Query) (rel.Cursor, error)
- func (adapter *Adapter) Rollback(ctx context.Context) error
- func (adapter *Adapter) Update(ctx context.Context, query rel.Query, mutates map[string]rel.Mutate) (int, error)
- type Buffer
- type Builder
- func (b *Builder) Aggregate(query rel.Query, mode string, field string) (string, []interface{})
- func (b *Builder) Delete(table string, filter rel.FilterQuery) (string, []interface{})
- func (b *Builder) Find(query rel.Query) (string, []interface{})
- func (b *Builder) Insert(table string, mutates map[string]rel.Mutate) (string, []interface{})
- func (b *Builder) InsertAll(table string, fields []string, bulkMutates []map[string]rel.Mutate) (string, []interface{})
- func (b *Builder) Returning(field string) *Builder
- func (b *Builder) Update(table string, mutates map[string]rel.Mutate, filter rel.FilterQuery) (string, []interface{})
- type Config
- type Cursor
Constants ¶
This section is empty.
Variables ¶
View Source
var UnescapeCharacter byte = '^'
UnescapeCharacter disable field escaping when it starts with this character.
Functions ¶
func ExtractString ¶
ExtractString between two string.
Types ¶
type Adapter ¶
type Adapter struct { Instrumenter rel.Instrumenter Config *Config DB *sql.DB Tx *sql.Tx // contains filtered or unexported fields }
Adapter definition for database database.
func (*Adapter) Aggregate ¶
func (adapter *Adapter) Aggregate(ctx context.Context, query rel.Query, mode string, field string) (int, error)
Aggregate record using given query.
func (*Adapter) Exec ¶
func (adapter *Adapter) Exec(ctx context.Context, statement string, args []interface{}) (int64, int64, error)
Exec performs exec operation.
func (*Adapter) Insert ¶
func (adapter *Adapter) Insert(ctx context.Context, query rel.Query, mutates map[string]rel.Mutate) (interface{}, error)
Insert inserts a record to database and returns its id.
func (*Adapter) InsertAll ¶
func (adapter *Adapter) InsertAll(ctx context.Context, query rel.Query, fields []string, bulkMutates []map[string]rel.Mutate) ([]interface{}, error)
InsertAll inserts all record to database and returns its ids.
func (*Adapter) Instrument ¶ added in v0.3.0
Instrument call instrumenter, if no instrumenter is set, this will be a no op.
func (*Adapter) Instrumentation ¶ added in v0.3.0
func (adapter *Adapter) Instrumentation(instrumenter rel.Instrumenter)
Instrumentation set instrumenter for this adapter.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder defines information of query b.
func (*Builder) Delete ¶
func (b *Builder) Delete(table string, filter rel.FilterQuery) (string, []interface{})
Delete generates query for delete.
func (*Builder) InsertAll ¶
func (b *Builder) InsertAll(table string, fields []string, bulkMutates []map[string]rel.Mutate) (string, []interface{})
InsertAll generates query for multiple insert.
Click to show internal directories.
Click to hide internal directories.