Documentation ¶
Index ¶
- Constants
- Variables
- func Placeholders(count int) string
- func Scan(rows *sql.Rows, result *[]map[string]interface{})
- func String(tmplname, tmpl string, data interface{}, pf PlaceholderFormat) (string, error)
- func StringBlock(tmplname, tmpl string, block string, data interface{}, pf PlaceholderFormat) (string, error)
- type Column
- type DMLSchema
- type IVendor
- type Index
- type PlaceholderFormat
- type Table
Constants ¶
View Source
const (
// Update used for update_at column
Update = "on update CURRENT_TIMESTAMP"
)
Variables ¶
View Source
var ( // Question is a PlaceholderFormat instance that leaves placeholders as // question marks. Question = questionFormat{} // Dollar is a PlaceholderFormat instance that replaces placeholders with // dollar-prefixed positional placeholders (e.g. $1, $2, $3). Dollar = dollarFormat{} // Colon is a PlaceholderFormat instance that replaces placeholders with // colon-prefixed positional placeholders (e.g. :1, :2, :3). Colon = colonFormat{} // AtP is a PlaceholderFormat instance that replaces placeholders with // "@p"-prefixed positional placeholders (e.g. @p1, @p2, @p3). AtP = atpFormat{} )
View Source
var Registry = ®istry{ vendors: map[string]IVendor{}, }
Functions ¶
func Placeholders ¶
Placeholders returns a string with count ? placeholders joined with commas.
func String ¶
func String(tmplname, tmpl string, data interface{}, pf PlaceholderFormat) (string, error)
func StringBlock ¶
func StringBlock(tmplname, tmpl string, block string, data interface{}, pf PlaceholderFormat) (string, error)
Types ¶
type Column ¶
type Column struct { TablePrefix string Table string Name string OldName string Type string Default *string Pk bool Nullable bool Unsigned bool Autoincrement bool Extra string Comment string // 关联表名 Foreign string }
Column define a column
type IVendor ¶
type IVendor interface { CreateTable(ctx context.Context, db *gorm.DB, t Table) error DropTable(ctx context.Context, db *gorm.DB, t Table) error ChangeColumn(ctx context.Context, db *gorm.DB, col Column) error AddColumn(ctx context.Context, db *gorm.DB, col Column) error DropColumn(ctx context.Context, db *gorm.DB, col Column) error ToColumnType(goType string, autoincrementing bool) string Insert(ctx context.Context, db *gorm.DB, dml DMLSchema, args ...interface{}) (int64, error) Update(ctx context.Context, db *gorm.DB, dml DMLSchema, args ...interface{}) error Delete(ctx context.Context, db *gorm.DB, dml DMLSchema, args ...interface{}) error SelectById(ctx context.Context, db *gorm.DB, dml DMLSchema, args ...interface{}) (map[string]interface{}, error) GetInsertStatement(dml DMLSchema) (statement string, err error) GetInsertReturningPkStatement(dml DMLSchema) (statement string, err error) GetBatchInsertStatement(dml DMLSchema, rows []interface{}) (statement string, err error) GetUpdateStatement(dml DMLSchema) (statement string, err error) }
type PlaceholderFormat ¶
PlaceholderFormat is the interface that wraps the ReplacePlaceholders method.
ReplacePlaceholders takes a SQL statement and replaces each question mark placeholder with a (possibly different) SQL placeholder.
Click to show internal directories.
Click to hide internal directories.