db

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TmFmtWithMS = "2006-01-02 15:04:05.999"
	NullStr     = "NULL"
)
View Source
const (
	ColumnDeletedAt = "deleted_at"
	ColumnId        = "id"
	ColumnName      = "name"
)
View Source
const (
	ExprEqual    = " = ?"
	ExprNotEqual = " != ?"
	ExprGreater  = " > ?"
)
View Source
const (
	Mysql    = "mysql"
	Postgres = "postgres"
	Sqlite   = "sqlite"
)
View Source
const (
	INSERT    = "INSERT"
	SELECT    = "SELECT"
	UPDATE    = "UPDATE"
	DELETE    = "DELETE"
	LEFTJOIN  = "LEFT JOIN"
	RIGHTJOIN = "RIGHT JOIN"
	INNERJOIN = "INNER JOIN"
)
View Source
const (
	NotDeleted     = ColumnDeletedAt + " IS " + NullStr
	WithNotDeleted = ` AND ` + NotDeleted
)

Variables

This section is empty.

Functions

func ConvertParams

func ConvertParams(v interface{}, escaper string) string

func TableName

func TableName(name string, id uint64) string

Types

type Config

type Config struct {
	Type, Charset, Database, TimeZone string
	Host                              string `flag:"name:db_host;usage:数据库host"`
	User, Password                    string
	TimeFormat                        string
	MaxIdleConns, MaxOpenConns        int
	Port                              int32
}

type Deleted

type Deleted struct {
	DeleteAt, Time string
}

func DeletedAt

func DeletedAt(t string) *Deleted

type FilterExpression

type FilterExpression struct {
	Field     string        `json:"field"`
	Operation Operation     `json:"method"`
	Value     []interface{} `json:"value"`
}

type FilterExpressions

type FilterExpressions []FilterExpression

func (FilterExpressions) Build

func (f FilterExpressions) Build() string

func (FilterExpressions) BuildORM

func (f FilterExpressions) BuildORM(odb *gorm.DB) *gorm.DB

func (FilterExpressions) BuildSQL

func (f FilterExpressions) BuildSQL() (string, []interface{})

type Operation

type Operation int
const (
	OperationPlace Operation = iota
	Equal
	NotEqual
	Greater
	Less
	Between
	GreaterOrEqual
	LessOrEqual
	IsNotNull
	IsNull
	In
	NotIn
	LIKE
)

func (Operation) SQL

func (m Operation) SQL() string

func (Operation) String

func (m Operation) String() string

type TimeModel

type TimeModel struct {
	CreatedAt time.Time  `json:"created_at" gorm:"default:current_timestamp"`
	UpdatedAt time.Time  `json:"updated_at"  gorm:"default:current_timestamp"`
	DeletedAt *time.Time `json:"deleted_at"`
}

type TimeStampModel

type TimeStampModel struct {
	CreatedAt int64 `json:"created_at" gorm:"default:current_timestamp"`
	UpdatedAt int64 `json:"updated_at" gorm:"default:current_timestamp"`
	DeletedAt int64 `json:"deleted_at"`
}

type TimeStringModel

type TimeStringModel struct {
	CreatedAt string `json:"created_at" gorm:"default:current_timestamp"`
	UpdatedAt string `json:"updated_at" gorm:"default:current_timestamp"`
	DeletedAt string `json:"deleted_at"`
}

Jump to

Keyboard shortcuts

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