Documentation ¶
Overview ¶
Package sql is general sql adapter that wraps database/sql.
Index ¶
- Variables
- func Escape(config Config, field string) string
- func ExtractString(s, left, right string) string
- func MapColumn(column *rel.Column) (string, int, int)
- type Adapter
- func (a *Adapter) Aggregate(ctx context.Context, query rel.Query, mode string, field string) (int, error)
- func (a *Adapter) Apply(ctx context.Context, migration rel.Migration) error
- func (a *Adapter) Begin(ctx context.Context) (rel.Adapter, error)
- func (a *Adapter) Close() error
- func (a *Adapter) Commit(ctx context.Context) error
- func (a *Adapter) Delete(ctx context.Context, query rel.Query) (int, error)
- func (a *Adapter) Exec(ctx context.Context, statement string, args []interface{}) (int64, int64, error)
- func (a *Adapter) Insert(ctx context.Context, query rel.Query, primaryField string, ...) (interface{}, error)
- func (a *Adapter) InsertAll(ctx context.Context, query rel.Query, primaryField string, fields []string, ...) ([]interface{}, error)
- func (a *Adapter) Instrumentation(instrumenter rel.Instrumenter)
- func (a *Adapter) Ping(ctx context.Context) error
- func (a *Adapter) Query(ctx context.Context, query rel.Query) (rel.Cursor, error)
- func (a *Adapter) Rollback(ctx context.Context) error
- func (a *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) Index(index rel.Index) string
- 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) Table(table rel.Table) string
- 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 (a *Adapter) Aggregate(ctx context.Context, query rel.Query, mode string, field string) (int, error)
Aggregate record using given query.
func (*Adapter) Exec ¶
func (a *Adapter) Exec(ctx context.Context, statement string, args []interface{}) (int64, int64, error)
Exec performs exec operation.
func (*Adapter) Insert ¶
func (a *Adapter) Insert(ctx context.Context, query rel.Query, primaryField string, mutates map[string]rel.Mutate) (interface{}, error)
Insert inserts a record to database and returns its id.
func (*Adapter) InsertAll ¶
func (a *Adapter) InsertAll(ctx context.Context, query rel.Query, primaryField string, fields []string, bulkMutates []map[string]rel.Mutate) ([]interface{}, error)
InsertAll inserts all record to database and returns its ids.
func (*Adapter) Instrumentation ¶
func (a *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.
type Config ¶
type Config struct { Placeholder string Ordinal bool InsertDefaultValues bool DropIndexOnTable bool EscapeChar string ErrorFunc func(error) error IncrementFunc func(Adapter) int IndexToSQL func(config Config, buffer *Buffer, index rel.Index) bool MapColumnFunc func(column *rel.Column) (string, int, int) }
Config holds configuration for adapter.
Click to show internal directories.
Click to hide internal directories.