Documentation ¶
Index ¶
- Constants
- func Columns(cols ...string) []string
- func RegisterDialect(name string, d *Dialect)
- type Config
- type Dialect
- type FootREST
- func (r *FootREST) BuildDeleteStmt(table string, whereSExpr string) (string, []any, error)
- func (r *FootREST) BuildGetStmt(table string, selColumns []string, whereSExpr string, orderColumns []string, ...) (string, []any, error)
- func (r *FootREST) BuildPostStmt(table string, values any) (string, []any, error)
- func (r *FootREST) BuildPutStmt(table string, values map[string]any, whereSExpr string) (string, []any, error)
- func (r *FootREST) Bulk(ctx context.Context, b bulkReq) (int64, error)
- func (r *FootREST) BulkGet(ctx context.Context, b bulkGetReq) (bulkRecordSet, error)
- func (r *FootREST) Delete(ctx context.Context, table string, where string) (int64, error)
- func (r *FootREST) Get(ctx context.Context, table string, selColumns []string, whereSExpr string, ...) (recordSet, error)
- func (r *FootREST) Post(ctx context.Context, table string, values any) (int64, error)
- func (r *FootREST) Put(ctx context.Context, table string, set map[string]any, where string) (int64, error)
- func (r *FootREST) Serve()
- type Operator
- type OperatorFormatter
- type ResponseFormat
- type SPParam
- type SpecialParams
Constants ¶
View Source
const DefaultOperatorFormat = `$1 {OPERATOR} $2`
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Format ResponseFormat Params SpecialParams Timeout int64 Addr string Root string }
func DefaultConfig ¶
func DefaultConfig() *Config
type Dialect ¶
type Dialect struct { Operators map[string]Operator // key(Operator.Name) must be upper case. Placeholder func(int) string Arg func(int, any) any IsValidName func(string) bool Paginate func(uint, uint) [2]string // (rows_per_page,page) -> stmt }
The best way to define a dialect is use DefaultDialect() and tweek the returned dialect.
func DefaultDialect ¶
func DefaultDialect() Dialect
func GetDialect ¶
func (*Dialect) AddOperator ¶
func (d *Dialect) AddOperator(name string, format string, f ...OperatorFormatter)
type FootREST ¶
type FootREST struct {
// contains filtered or unexported fields
}
func New ¶
func New(conn *sql.DB, dialect string, enc encoding.Encoding, useSchema bool, config *Config) *FootREST
New creates new FootREST with already Opened connection(*sql.DB).
func NewConn ¶
func NewConn(driverName, dataSourceName string, enc encoding.Encoding, useSchema bool, config *Config) (*FootREST, *sql.DB, error)
NewConn opens a connection and creates new FootREST with the conn.
func (*FootREST) BuildDeleteStmt ¶
func (*FootREST) BuildGetStmt ¶
func (*FootREST) BuildPostStmt ¶
func (*FootREST) BuildPutStmt ¶
type Operator ¶
type Operator struct { Name string Format string // "$1 == $2", "$1 BETWEEN $2 AND $3" Formatter OperatorFormatter // optional }
type OperatorFormatter ¶
type ResponseFormat ¶
Click to show internal directories.
Click to hide internal directories.