Documentation ¶
Index ¶
- type Database
- type PostgresDatabase
- func (p *PostgresDatabase) Close() error
- func (p *PostgresDatabase) Delete(ctx context.Context, key string, model interface{}) error
- func (p *PostgresDatabase) Get(ctx context.Context, key string, result interface{}) error
- func (p *PostgresDatabase) GetAll(ctx context.Context, model interface{}, limit, offset int) ([]interface{}, error)
- func (p *PostgresDatabase) Insert(ctx context.Context, value interface{}) error
- func (p *PostgresDatabase) Update(ctx context.Context, key string, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { Insert(ctx context.Context, value interface{}) error Update(ctx context.Context, key string, value interface{}) error Delete(ctx context.Context, key string) error Get(ctx context.Context, key string, result interface{}) error GetAll(ctx context.Context, model interface{}, limit, offset int) ([]interface{}, error) }
Database interface defines the operations for any database (Insert, Update, Delete, Get, and GetAll)
type PostgresDatabase ¶
type PostgresDatabase struct {
// contains filtered or unexported fields
}
PostgresDatabase struct represents a connection to a PostgreSQL database
func InitPostgres ¶
func InitPostgres(addr, user, password, dbName string) (*PostgresDatabase, error)
InitPostgres initializes the PostgreSQL connection and ensures the connection is active
func NewPostgresDatabase ¶
func NewPostgresDatabase(addr, user, password, dbName string) (*PostgresDatabase, error)
func (*PostgresDatabase) Close ¶
func (p *PostgresDatabase) Close() error
func (*PostgresDatabase) Delete ¶
func (p *PostgresDatabase) Delete(ctx context.Context, key string, model interface{}) error
Delete implements the Delete method of the Database interface Delete implements the Delete method of the Database interface
func (*PostgresDatabase) Get ¶
func (p *PostgresDatabase) Get(ctx context.Context, key string, result interface{}) error
Get implements the Get method of the Database interface
func (*PostgresDatabase) GetAll ¶
func (p *PostgresDatabase) GetAll(ctx context.Context, model interface{}, limit, offset int) ([]interface{}, error)
GetAll retrieves all records of the given model with optional pagination
Click to show internal directories.
Click to hide internal directories.