Versions in this module Expand all Collapse all v3 v3.2.0 Apr 7, 2021 Changes in this version + const TimeFormatLayout type Column + PrimitiveType PrimitiveType + func NewColumn(p PrimitiveType) (*Column, error) + type PrimitiveType int + const Auto + const Bool + const Bytes + const Float32 + const Float64 + const Int + const Int16 + const Int32 + const Int64 + const Int8 + const NullBool + const NullFloat64 + const NullInt32 + const NullInt64 + const NullString + const NullTime + const RawBytes + const String + const Time + const Uint + const Uint16 + const Uint32 + const Uint64 + const Uint8 + func GetPrimitiveType(t reflect.Type) PrimitiveType + type PrimitiveTyper interface + PrimitiveType func() PrimitiveType type Unix + IsNull bool + func (n *Unix) FromTime(t time.Time) + func (n *Unix) ParseDefault(v string) error + func (n *Unix) UnmarshalBinary(data []byte) error + func (n *Unix) UnmarshalJSON(data []byte) error + func (n *Unix) UnmarshalText(data []byte) error + func (n Unix) MarshalBinary() ([]byte, error) + func (n Unix) MarshalJSON() ([]byte, error) + func (n Unix) MarshalText() ([]byte, error) + func (n Unix) PrimitiveType() PrimitiveType v3.1.0 Dec 2, 2020 Changes in this version + var UnixType = reflect.TypeOf(Unix{}) + type Unix time.Time + func (n *Unix) Scan(value interface{}) error + func (n Unix) Value() (driver.Value, error) v3.0.0 Oct 23, 2020 Changes in this version + const QuoteLeft + const QuoteRight + var BoolType = reflect.TypeOf(true) + var ErrAutoIncrementPrimaryKeyConflict = errors.New("自增和主键不能同时存在") + var ErrColumnMustNumber = errors.New("类型必须为数值") + var ErrInvalidColumnType = errors.New("无效的列类型") + var Float32Type = reflect.TypeOf(float32(1)) + var Float64Type = reflect.TypeOf(float64(1)) + var Int16Type = reflect.TypeOf(int16(1)) + var Int32Type = reflect.TypeOf(int32(1)) + var Int64Type = reflect.TypeOf(int64(1)) + var Int8Type = reflect.TypeOf(int8(1)) + var IntType = reflect.TypeOf(int(1)) + var NullBoolType = reflect.TypeOf(sql.NullBool{}) + var NullFloat64Type = reflect.TypeOf(sql.NullFloat64{}) + var NullInt32Type = reflect.TypeOf(sql.NullInt32{}) + var NullInt64Type = reflect.TypeOf(sql.NullInt64{}) + var NullStringType = reflect.TypeOf(sql.NullString{}) + var NullTimeType = reflect.TypeOf(sql.NullTime{}) + var RawBytesType = reflect.TypeOf(sql.RawBytes{}) + var StringType = reflect.TypeOf("") + var TimeType = reflect.TypeOf(time.Time{}) + var Uint16Type = reflect.TypeOf(uint16(1)) + var Uint32Type = reflect.TypeOf(uint32(1)) + var Uint64Type = reflect.TypeOf(uint64(1)) + var Uint8Type = reflect.TypeOf(uint8(1)) + var UintType = reflect.TypeOf(uint(1)) + func AIName(table string) string + func ErrConstraintExists(c string) error + func PKName(table string) string + type Builder struct + func NewBuilder(str ...string) *Builder + func (b *Builder) Append(v *Builder) *Builder + func (b *Builder) Bytes() ([]byte, error) + func (b *Builder) Err() error + func (b *Builder) Len() int + func (b *Builder) Quote(str string, l, r byte) *Builder + func (b *Builder) QuoteKey(str string) *Builder + func (b *Builder) Reset() *Builder + func (b *Builder) String() (string, error) + func (b *Builder) TruncateLast(n int) *Builder + func (b *Builder) WBytes(c ...byte) *Builder + func (b *Builder) WRunes(r ...rune) *Builder + func (b *Builder) WString(str string) *Builder + type Column struct + AI bool + Default interface{} + GoName string + GoType reflect.Type + HasDefault bool + Length []int + Name string + Nullable bool + func NewColumnFromGoType(goType reflect.Type) (*Column, error) + func (c *Column) Check() error + func (c *Column) Clone() *Column + func (c *Column) SetDefault(v interface{}) + type Constraint int8 + const ConstraintAI + const ConstraintCheck + const ConstraintFK + const ConstraintNone + const ConstraintPK + const ConstraintUnique + type DefaultParser interface + ParseDefault func(v string) error + type Dialect interface + CreateTableOptionsSQL func(sql *Builder, meta map[string][]string) error + DBName func() string + DriverName func() string + Fix func(query string, args []interface{}) (string, []interface{}, error) + LastInsertIDSQL func(table, col string) (sql string, append bool) + LimitSQL func(limit interface{}, offset ...interface{}) (string, []interface{}) + Prepare func(sql string) (query string, orders map[string]int, err error) + SQLType func(*Column) (string, error) + TransactionalDDL func() bool + VersionSQL func() string + type Engine interface + Dialect func() Dialect + Exec func(query string, args ...interface{}) (sql.Result, error) + ExecContext func(ctx context.Context, query string, args ...interface{}) (sql.Result, error) + Prepare func(query string) (*Stmt, error) + PrepareContext func(ctx context.Context, query string) (*Stmt, error) + Query func(query string, args ...interface{}) (*sql.Rows, error) + QueryContext func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) + QueryRow func(query string, args ...interface{}) *sql.Row + QueryRowContext func(ctx context.Context, query string, args ...interface{}) *sql.Row + TablePrefix func() string + type ForeignKey struct + Column *Column + DeleteRule string + RefColName string + RefTableName string + UpdateRule string + type Index int8 + const IndexDefault + const IndexUnique + type Metaer interface + Meta func() string + type Model struct + AutoIncrement *Column + Checks map[string]string + Columns []*Column + ForeignKeys map[string]*ForeignKey + GoType reflect.Type + Indexes map[string][]*Column + Meta map[string][]string + Name string + OCC *Column + PrimaryKey []*Column + Type ModelType + Uniques map[string][]*Column + ViewAs string + func NewModel(modelType ModelType, name string, cap int) *Model + func (m *Model) AIName() string + func (m *Model) AddColumn(col *Column) error + func (m *Model) AddColumns(col ...*Column) error + func (m *Model) AddIndex(typ Index, name string, col *Column) error + func (m *Model) AddPrimaryKey(col *Column) error + func (m *Model) AddUnique(name string, col *Column) error + func (m *Model) FindColumn(name string) *Column + func (m *Model) NewCheck(name string, expr string) error + func (m *Model) NewForeignKey(name string, fk *ForeignKey) error + func (m *Model) PKName() string + func (m *Model) Reset() + func (m *Model) Sanitize() error + func (m *Model) SetAutoIncrement(col *Column) error + func (m *Model) SetOCC(col *Column) error + type ModelType int8 + const Table + const View + type Stmt struct + func NewStmt(stmt *sql.Stmt, orders map[string]int) *Stmt + func (stmt *Stmt) Close() error + func (stmt *Stmt) Exec(args ...interface{}) (sql.Result, error) + func (stmt *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error) + func (stmt *Stmt) Query(args ...interface{}) (*sql.Rows, error) + func (stmt *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error) + func (stmt *Stmt) QueryRow(args ...interface{}) *sql.Row + func (stmt *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row + type Viewer interface + ViewAs func(e Engine) (string, error) Other modules containing this package github.com/issue9/orm/v4 github.com/issue9/orm/v5 github.com/issue9/orm/v6