postgre

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Conn added in v1.3.5

func Conn(cfg *gorm.Config) (db *gorm.DB)

func DB

func DB(isTest bool, cfg *gorm.Config) (DB *gorm.DB, sql_ *sql.DB)

func TestConn added in v1.3.5

func TestConn(cfg *gorm.Config) (db *gorm.DB)

Types

type DateTime added in v1.2.3

type DateTime int64

func (*DateTime) Scan added in v1.2.3

func (dt *DateTime) Scan(src interface{}) error

Scan implements sql.Scanner interface and scans value into Time,

func (DateTime) Value added in v1.2.3

func (dt DateTime) Value() (driver.Value, error)

type Model

type Model struct {
	ID        uint  `gorm:"primarykey;index" json:"id" form:"id"`
	CreatedAt int64 `gorm:"index" json:"created_at" form:"created_at"`
	UpdatedAt int64 `gorm:"index" json:"updated_at" form:"updated_at"`

	//Pagination and Filter
	Pagination Pagination `json:"-" form:"-" gorm:"-"`
	//Practice
	IsTest bool `json:"-" form:"tutorial" gorm:"-"`

	//ILike cond
	ILike   []string `json:"-" gorm:"-"`
	Preload []string `json:"-" gorm:"-"`
	// contains filtered or unexported fields
}

func (*Model) Bind added in v1.0.4

func (m *Model) Bind(ctx *gin.Context, data interface{}) (err error)

func (*Model) Create

func (m *Model) Create(data interface{}) (err error)

Create func for create data to table base on model in data params

func (*Model) Delete

func (m *Model) Delete(data interface{}, args ...interface{}) (err error)

Delete func for delete data from table base on model in data params and delete by args

func (*Model) GetNameOf added in v1.1.2

func (this *Model) GetNameOf(type_ interface{}, prefix string) string

GetNameOf is a func for get name of structor model and make if snake case

func (*Model) Read

func (m *Model) Read(data interface{}, args ...interface{}) (err error)

Read func for get data

func (*Model) SetConnection added in v1.1.9

func (m *Model) SetConnection(conn *gorm.DB) *Model

func (*Model) SetILike

func (m *Model) SetILike(ilike ...string) *Model

SetILike for add some ilike condition

func (*Model) SetPreload added in v1.0.3

func (m *Model) SetPreload(pre ...string) *Model

SetPreload func for add some preload relation to model

func (*Model) Update

func (m *Model) Update(data interface{}, args ...interface{}) (err error)

Update func for update data from table base on model in data params and update by args

type ModelDT added in v1.2.7

type ModelDT struct {
	ID        uint      `gorm:"primarykey;index" json:"id" form:"id"`
	CreatedAt time.Time `gorm:"index" json:"created_at" form:"created_at"`
	UpdatedAt time.Time `gorm:"index" json:"updated_at" form:"updated_at"`

	//Pagination and Filter
	Pagination PaginationDT `json:"-" form:"-" gorm:"-"`
	//Practice
	IsTest bool `json:"-" form:"tutorial" gorm:"-"`

	//ILike cond
	ILike   []string `json:"-" gorm:"-"`
	Preload []string `json:"-" gorm:"-"`
	// contains filtered or unexported fields
}

func (*ModelDT) Bind added in v1.2.7

func (m *ModelDT) Bind(ctx *gin.Context, data interface{}) (err error)

func (*ModelDT) Create added in v1.2.7

func (m *ModelDT) Create(data interface{}) (err error)

Create func for create data to table base on model in data params

func (*ModelDT) Delete added in v1.2.7

func (m *ModelDT) Delete(data interface{}, args ...interface{}) (err error)

Delete func for delete data from table base on model in data params and delete by args

func (*ModelDT) GetNameOf added in v1.2.7

func (this *ModelDT) GetNameOf(type_ interface{}, prefix string) string

GetNameOf is a func for get name of structor model and make if snake case

func (*ModelDT) Read added in v1.2.7

func (m *ModelDT) Read(data interface{}, args ...interface{}) (err error)

Read func for get data

func (*ModelDT) SetConnection added in v1.2.7

func (m *ModelDT) SetConnection(conn *gorm.DB) *ModelDT

func (*ModelDT) SetILike added in v1.2.7

func (m *ModelDT) SetILike(ilike ...string) *ModelDT

SetILike for add some ilike condition

func (*ModelDT) SetPreload added in v1.2.7

func (m *ModelDT) SetPreload(pre ...string) *ModelDT

SetPreload func for add some preload relation to model

func (*ModelDT) Update added in v1.2.7

func (m *ModelDT) Update(data interface{}, args ...interface{}) (err error)

Update func for update data from table base on model in data params and update by args

type PGSql added in v1.3.5

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

type Pagination

type Pagination struct {
	//Search
	Keyword   string `json:"-" form:"keyword"`
	StartDate int64  `json:"-" form:"start_date"`
	EndDate   int64  `json:"-" form:"end_date"`
	Sort      string `json:"-" form:"sort"`
	SortBy    string `json:"-" form:"sort_by"`

	//Pagination
	ShowAll   bool  `json:"-" form:"show_all"`
	Page      int64 `json:"current_page" form:"page"`
	PageSize  int64 `json:"page_size" form:"page_size"`
	TotalPage int64 `json:"page_total"`
	TotalData int64 `json:"data_total"`
	HasNext   bool  `json:"has_next"`
	HasPrev   bool  `json:"has_previous"`
}

type PaginationDT added in v1.2.7

type PaginationDT struct {
	//Search
	Keyword   string `json:"-" form:"keyword"`
	StartDate string `json:"-" form:"start_date"`
	EndDate   string `json:"-" form:"end_date"`
	Sort      string `json:"-" form:"sort"`
	SortBy    string `json:"-" form:"sort_by"`

	//Pagination
	ShowAll   bool  `json:"-" form:"show_all"`
	Page      int64 `json:"current_page" form:"page"`
	PageSize  int64 `json:"page_size" form:"page_size"`
	TotalPage int64 `json:"page_total"`
	TotalData int64 `json:"data_total"`
	HasNext   bool  `json:"has_next"`
	HasPrev   bool  `json:"has_previous"`
}

Jump to

Keyboard shortcuts

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