model

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2022 License: MIT Imports: 9 Imported by: 0

README

orm for golang generate

you can change the template as you like.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SummaryDBColumns = []string{
	"`id`",
	"`name`",
	"`age`",
	"`sex`",
}
View Source
var SummaryMgr *_SummaryMgr
View Source
var UserDBColumns = []string{
	"`id`",
	"`name`",
	"`age`",
	"`sex`",
	"`foo_bar`",
	"`create_at`",
	"`update_at`",
}
View Source
var UserDBTable = "user"
View Source
var UserMgr *_UserMgr

Functions

func DBMgr

func DBMgr(db DB) *_DBMgr

func SummaryDBMgr

func SummaryDBMgr(db DB) *_SummaryDBMgr

func UserDBMgr

func UserDBMgr(db DB) *_UserDBMgr

Types

type Cipher

type Cipher interface {
	Encode(string) string
	Decode(string) string
}

Cipher

var Encoder Cipher

type DB

type DB interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

type FieldIN

type FieldIN struct {
	Field  string
	Params []interface{}
	// contains filtered or unexported fields
}

In

func NewFieldIN

func NewFieldIN(field string) *FieldIN

func (*FieldIN) Add

func (in *FieldIN) Add(v interface{}) *FieldIN

func (*FieldIN) SQLFormat

func (in *FieldIN) SQLFormat() string

func (*FieldIN) SQLFormatNotIn

func (in *FieldIN) SQLFormatNotIn() string

func (*FieldIN) SQLParams

func (in *FieldIN) SQLParams() []interface{}

type Join

type Join struct {
	Method string
	Field1 *JoinField
	Field2 *JoinField
}

func On

func On(tb1 string, f1 string, tb2 string, f2 string) *Join

type JoinField

type JoinField struct {
	Table string
	Field string
}

type LOGDB

type LOGDB struct {
	// contains filtered or unexported fields
}

LOG

func LOG

func LOG(db DB) *LOGDB

func (*LOGDB) ExecContext

func (lg *LOGDB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*LOGDB) QueryContext

func (lg *LOGDB) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

type PasswordFunc

type PasswordFunc func(string) string

PasswordFunc

var Password PasswordFunc

utils

type Summary

type Summary struct {
	Id   int32  `json:"id" yaml:"id"`
	Name string `json:"name" yaml:"name"`
	Age  int32  `json:"age" yaml:"age"`
	Sex  bool   `json:"sex" yaml:"sex"`
}

type TableJoin

type TableJoin struct {
	// contains filtered or unexported fields
}

TableJoin

func NewTableJoin

func NewTableJoin(table string) *TableJoin

func (*TableJoin) Condition

func (tj *TableJoin) Condition(condition string, args ...interface{})

func (*TableJoin) Field

func (tj *TableJoin) Field(table string, fields ...string)

func (*TableJoin) Inner

func (tj *TableJoin) Inner(j *Join)

func (*TableJoin) Left

func (tj *TableJoin) Left(j *Join)

func (*TableJoin) Limit

func (tj *TableJoin) Limit(offset int, limit int)

func (*TableJoin) OrderBy

func (tj *TableJoin) OrderBy(orderby string)

func (*TableJoin) Right

func (tj *TableJoin) Right(j *Join)

func (*TableJoin) SQLFormat

func (tj *TableJoin) SQLFormat() string

func (*TableJoin) SQLParams

func (tj *TableJoin) SQLParams() []interface{}

func (*TableJoin) TableAlias

func (tj *TableJoin) TableAlias(table string, alias string)

type User

type User struct {
	Id       int32      `json:"id" yaml:"id"`
	Name     string     `json:"name" yaml:"name"`
	Age      int32      `json:"age" yaml:"age"`
	Sex      bool       `json:"sex" yaml:"sex"`
	FooBar   int32      `json:"foo" yaml:"bar"`
	CreateAt time.Time  `json:"createAt" yaml:"createAt"`
	UpdateAt *time.Time `json:"updateAt" yaml:"updateAt"`
}

type UserAgeSexIndex

type UserAgeSexIndex struct {
	Age int32
	Sex bool
}

func (*UserAgeSexIndex) DBColumns

func (u *UserAgeSexIndex) DBColumns() []string

func (*UserAgeSexIndex) SQLFormat

func (u *UserAgeSexIndex) SQLFormat() []string

func (*UserAgeSexIndex) SQLParams

func (u *UserAgeSexIndex) SQLParams() []interface{}

type UserNameUK

type UserNameUK struct {
	Name string
}

func (*UserNameUK) DBColumns

func (u *UserNameUK) DBColumns() []string

func (*UserNameUK) SQLFormat

func (u *UserNameUK) SQLFormat() []string

func (*UserNameUK) SQLParams

func (u *UserNameUK) SQLParams() []interface{}

type UserPK

type UserPK struct {
	Id int32
}

func (*UserPK) DBColumns

func (u *UserPK) DBColumns() []string

func (*UserPK) SQLFormat

func (u *UserPK) SQLFormat() []string

func (*UserPK) SQLParams

func (u *UserPK) SQLParams() []interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL