Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package postgres provides PostgreSQL-specific utilities including pagination helpers, database connection management, and migration support for PostgreSQL databases.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pagination ¶
type Pagination struct {
	Items      any       `json:"items"`
	Page       int       `json:"page,omitempty" example:"1"`
	PrevCursor string    `json:"prev_cursor,omitempty" example:"MDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwMA==" extensions:"x-omitempty"`
	NextCursor string    `json:"next_cursor,omitempty" example:"MDAwMDAwMDAtMDAwMC0wMDAwLTAwMDAtMDAwMDAwMDAwMDAwMA==" extensions:"x-omitempty"`
	Limit      int       `json:"limit" example:"10"`
	SortOrder  string    `json:"-" example:"asc"`
	StartDate  time.Time `json:"-" example:"2021-01-01"`
	EndDate    time.Time `json:"-" example:"2021-12-31"`
} // @name Pagination
    Pagination is a struct designed to encapsulate pagination response payload data.
swagger:model Pagination @Description Pagination is the struct designed to store the pagination data of an entity list.
func (*Pagination) SetCursor ¶
func (p *Pagination) SetCursor(next, prev string)
SetCursor set the next and previous cursor.
func (*Pagination) SetItems ¶
func (p *Pagination) SetItems(items any)
SetItems set an array of any struct in items.
type PostgresConnection ¶
type PostgresConnection struct {
	ConnectionStringPrimary string
	ConnectionStringReplica string
	PrimaryDBName           string
	ReplicaDBName           string
	ConnectionDB            dbresolver.DB
	Connected               bool
	Component               string
	MigrationsPath          string
	Logger                  log.Logger
	MaxOpenConnections      int
	MaxIdleConnections      int
}
    PostgresConnection is a hub which deal with postgres connections. The type name intentionally matches the package name for clarity in external usage.
func (*PostgresConnection) Connect ¶
func (pc *PostgresConnection) Connect() error
Connect keeps a singleton connection with postgres.
func (*PostgresConnection) GetDB ¶
func (pc *PostgresConnection) GetDB() (dbresolver.DB, error)
GetDB returns a pointer to the postgres connection, initializing it if necessary.